PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
peb_shape.c
1 #include "simpletools.h"
2 #include "badgetools.h"
3 
4 volatile screen *self;
5 
6 void shape(char *img, int bw, int xtl, int ytl, int xpics, int ypics)
7 {
8  int byte, bit, pix = 0, xp, yp, bytep, bitp, pixp = 0, n;
9  uint32_t screenbuf = screen_getBuffer();
10  char *scrbuf = (char *) screenbuf;
11  for(int x = 0; x < xpics; x++)
12  {
13  for(int y = 0; y < ypics; y++)
14  {
15  n = (y * xpics) + x;
16  byte = n / 8;
17  bit = 7 - (n % 8);
18  pix = (bw & 1) & (img[byte] >> bit);
19  pix ^= (bw >> 1);
20  pix &= 1;
21 
22  scrbuf[byte] &= ~(1 << bit);
23  scrbuf[byte] |= (pixp << bit);
24 
25  xp = xtl + x;
26  yp = ytl + y;
27 
28  bytep = ((yp >> 3) << 7) + xp;
29  bitp = yp % 8;
30  scrbuf[bytep] &= ~(1 << bitp);
31  scrbuf[bytep] |= (pix << bitp);
32  }
33  }
34 }
35 
36 /*
37  TERMS OF USE: MIT License
38 
39  Permission is hereby granted, free of charge, to any person obtaining a
40  copy of this software and associated documentation files (the "Software"),
41  to deal in the Software without restriction, including without limitation
42  the rights to use, copy, modify, merge, publish, distribute, sublicense,
43  and/or sell copies of the Software, and to permit persons to whom the
44  Software is furnished to do so, subject to the following conditions:
45 
46  The above copyright notice and this permission notice shall be included in
47  all copies or substantial portions of the Software.
48 
49  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
50  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
52  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
53  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
54  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
55  DEALINGS IN THE SOFTWARE.
56 */
57 
shape
void shape(char *img, int bw, int xtl, int ytl, int xpics, int ypics)
Place a shape defined by a char array of pixels on the oLED display. See 11 Shapes to Display....
Definition: peb_shape.c:6
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
x
int x
Definition: 07 Box and Lines.c:13
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.
screen
Definition: badgetools.h:1709