badgetools library  v0.51.1
Collection of convenience functions for the Parallax eBadge
badgetools.h
Go to the documentation of this file.
1 
44 #include "simpletools.h"
45 #include <stdint.h>
46 
47 #ifndef BADGETOOLS_H
48 #define BADGETOOLS_H
49 
50 #if defined(__cplusplus)
51 extern "C" {
52 #endif
53 
59 #ifndef ON
60 
64 #define ON 1
65 #endif
66 
67 #ifndef OFF
68 
73 #define OFF 0
74 #endif
75 
83 #ifndef L
84 
88 #define L 1
89 #endif
90 
91 #ifndef R
92 
96 #define R 0
97 #endif
98 
99 #ifndef BLUE
100 
104 #define BLUE (1)
105 #endif
106 
107 #ifndef GREEN
108 
112 #define GREEN (2)
113 #endif
114 
115 #ifndef CYAN
116 
120 #define CYAN (3)
121 #endif
122 
123 #ifndef RED
124 
128 #define RED (4)
129 #endif
130 
131 #ifndef MAGENTA
132 
136 #define MAGENTA (5)
137 #endif
138 
139 #ifndef YELLOW
140 
144 #define YELLOW (6)
145 #endif
146 
147 #ifndef WHITE
148 
152 #define WHITE (7)
153 #endif
154 
162 #ifndef SCR_BLACK
163 
167 #define SCR_BLACK (0)
168 #endif
169 
170 #ifndef SCR_WHITE
171 
175 #define SCR_WHITE (1)
176 #endif
177 
178 #ifndef SCR_XOR
179 
184 #define SCR_XOR (3)
185 #endif
186 
187 #ifndef LARGE
188 
192 #define LARGE 1
193 #endif
194 
195 #ifndef SMALL
196 
200 #define SMALL 0
201 #endif
202 
210 #ifndef AY
211 
215 #define AY 0
216 #endif
217 
218 #ifndef AX
219 
223 #define AX 1
224 #endif
225 
226 #ifndef AZ
227 
231 #define AZ 2
232 #endif
233 
249 int badge_setup( void );
250 
275 void led(int n, int state);
276 
290 void leds(int bits);
291 
305 void rgb(int side, int color);
306 
315 void rgbs(int colorL, int colorR);
316 
335 int button( int pad );
336 
350 int buttons( void );
351 
371 int accel(int axis);
372 
383 void accels(int *x, int *y, int *z);
384 
391 int accel_shaken(void);
392 
411 int store(char *contact);
412 
423 int stored(char * s);
424 
436 void retrieve(char *contact, int recIdx);
437 
455 int eeprint(const char *fmt, ...);
456 
469 int eeprinted(const char *fmt, ...);
470 
490 int eescan(int recIdx, const char *fmt, ...);
491 
498 int contacts_count();
499 
504 void contacts_eraseAll();
505 
509 void contacts_displayAll();
510 
518 void contacts_setStartAddr(int address);
519 
529 void ee_writeByte(unsigned char value, int addr);
530 
540 char ee_readByte(int addr);
541 
551 void ee_writeShort(short value, int addr);
552 
562 short ee_readShort(int addr);
563 
573 void ee_writeInt(int value, int addr);
574 
584 int ee_readInt(int addr);
585 
600 void ee_writeFloat32(float fpVal, int addr);
601 
602 
618 float ee_readFloat32(int addr);
619 
630 void ee_writeStr(char *s, int n, int addr);
631 
646 char* ee_readStr(unsigned char *s, int n, int addr);
647 
648 
649 //void contacts_clear(void);
650 //void contacts_setEndAddr(int address);
651 
667 int send(char *s);
668 
679 int receive(char *s);
680 
686 void irclear(void);
687 
706 int irprint(const char *fmt, ...);
707 
726 int irscan(const char *fmt, ...);
727 
738 void ir_send(char *s, int ssize);
739 
753 int ir_receive(char *s, int ssize);
754 
780 int oledprint(const char *fmt, ...);
781 
789 void text_size(int size);
790 
801 void cursor(int col, int row);
802 
811 void string(char *str);
812 
818 int clear( void );
819 
825 void invert(int i);
826 
838 void point( int x, int y, int color);
839 
857 void line( int x0, int y0, int x1, int y1, int c);
858 
876 void box( int x0, int y0, int x1, int y1, int c);
877 
895 void boxFilled( int x0, int y0, int x1, int y1, int c);
896 
918 void triangle( int x0, int y0, int x1, int y1, int x2, int y2, int c);
919 
941 void triangleFilled( int x0, int y0, int x1, int y1, int x2, int y2, int c);
942 
958 void circle( int x0, int y0, int r, int c);
959 
975 void circleFilled( int x0, int y0, int r, int c);
976 
994 void shape(char *img, int bw, int xtl, int ytl, int xpics, int ypics);
995 
1000 void rotate180();
1001 
1010 void screen_auto(int state);
1011 
1020 int screen_getAuto();
1021 
1029 int screen_update( void );
1030 
1043 int screen_scrollRight( int scrollStart, int scrollStop);
1044 
1050 int screen_scrollLeft( int scrollStart, int scrollStop);
1051 
1058 int screen_scrollRightDiag( int scrollStart, int scrollStop);
1059 
1066 int screen_scrollLeftDiag( int scrollStart, int scrollStop);
1067 
1073 int screen_scrollStop( void );
1074 
1090 void screen_image(char *imgaddr);
1091 
1099 // Handy tools
1100 
1110 void dev_ee_show(int byteCount, int address);
1111 
1112 
1118 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1119 
1120 /* =========================================================================== */
1121 // PRIVATE FUNCTIONS/MACROS
1122 /* =========================================================================== */
1123 
1130 // More LED control
1131 // charlieplex control for blue leds
1132 
1133 
1134 #ifndef BLUE_0
1135 #define BLUE_0 (0)
1136 #endif
1137 
1138 #ifndef BLUE_1
1139 #define BLUE_1 (1)
1140 #endif
1141 
1142 #ifndef BLUE_2
1143 #define BLUE_2 (2)
1144 #endif
1145 
1146 #ifndef BLUE_3
1147 #define BLUE_3 (3)
1148 #endif
1149 
1150 #ifndef BLUE_4
1151 #define BLUE_4 (4)
1152 #endif
1153 
1154 #ifndef BLUE_5
1155 #define BLUE_5 (5)
1156 #endif
1157 
1158 // charlieplex control for rgb leds
1159 #ifndef RGB_B1
1160 #define RGB_B1 (0)
1161 #endif
1162 
1163 #ifndef RGB_G1
1164 #define RGB_G1 (1)
1165 #endif
1166 
1167 #ifndef RGB_R1
1168 #define RGB_R1 (2)
1169 #endif
1170 
1171 #ifndef RGB_B2
1172 #define RGB_B2 (3)
1173 #endif
1174 
1175 #ifndef RGB_G2
1176 #define RGB_G2 (4)
1177 #endif
1178 
1179 #ifndef RGB_R2
1180 #define RGB_R2 (5)
1181 #endif
1182 
1183 /* fixed io pins */
1184 // blue led charlieplex pins
1185 #ifndef BLU_CP2
1186 #define BLU_CP2 (8)
1187 #endif
1188 
1189 #ifndef BLU_CP1
1190 
1193 #define BLU_CP1 (7)
1194 #endif
1195 
1196 #ifndef BLU_CP0
1197 
1200 #define BLU_CP0 (6)
1201 #endif
1202 // rgb led charlieplex pins
1203 #ifndef RGB_CP2
1204 
1207 #define RGB_CP2 (3)
1208 #endif
1209 
1210 #ifndef RGB_CP1
1211 
1214 #define RGB_CP1 (2)
1215 #endif
1216 
1217 #ifndef RGB_CP0
1218 
1221 #define RGB_CP0 (1)
1222 #endif
1223 
1224 typedef struct light {
1225 // cog running led driver
1226  volatile int cog;
1227 // active leds (blue in byte0, rgb in byte1)
1228  volatile int ledbits;
1229 // ticks in refresh cycle
1230  volatile int cycleticks;
1231 } light;
1232 
1233 void light_set_rgb1( int bits);
1234 void light_set_rgb2( int bits);
1235 void light_set_rgb( int bits);
1236 void light_set_all( int bits);
1237 void light_clear( void );
1238 void light_stop( void );
1239 void led_on(int32_t n);
1240 void led_off(int32_t n);
1241 
1242 int32_t ircom_start(int32_t rxd, int32_t txd, int32_t baud, int32_t freq);
1243 void ircom_stop(void);
1244 int32_t ircom_rx(void);
1245 int32_t ircom_rxcheck(void);
1246 int32_t ircom_rxtime(int32_t mslim);
1247 int32_t ircom_rxflush(void);
1248 int32_t ircom_tx(int32_t c);
1249 int32_t ircom_str(char *p_zstr);
1250 int32_t ircom_dec(int32_t value);
1251 int32_t ircom_rjdec(int32_t val, int32_t width, int32_t pchar);
1252 int32_t ircom_hex(int32_t value, int32_t digits);
1253 int32_t ircom_tx_bin(int32_t value, int32_t digits);
1254 int32_t ircom_txflush(void);
1255 
1256 
1257 typedef struct touch {
1258 // # of pins scanned
1259  volatile int pincount;
1260 // pointer to list of pins (byte array)
1261  volatile int p_pinslist;
1262 // discharge timing
1263  volatile int disch;
1264 // mask for input pins
1265  volatile int pinsmask;
1266 } touch;
1267 
1268 
1269 //extern char beanie[LCD_BUFFER_SIZE_BOTH_TYPES];
1270 
1271 // touch buttons (left)
1272 #ifndef BTN_0
1273 #define BTN_0 (27)
1274 #endif
1275 
1276 #ifndef BTN_1
1277 #define BTN_1 (26)
1278 #endif
1279 
1280 #ifndef BTN_2
1281 #define BTN_2 (25)
1282 #endif
1283 // touch buttons (right)
1284 #ifndef BTN_5
1285 #define BTN_5 (17)
1286 #endif
1287 
1288 #ifndef BTN_4
1289 #define BTN_4 (16)
1290 #endif
1291 
1292 #ifndef BTN_3
1293 #define BTN_3 (15)
1294 #endif
1295 // open source logo button
1296 #ifndef BTN_OS
1297 #define BTN_OS (5)
1298 #endif
1299 
1300 /* max supported using IR connection */
1301 #ifndef IR_BAUD
1302 #define IR_BAUD (2400)
1303 #endif
1304 /* matches receiver on DC22 badge */
1305 #ifndef IR_FREQ
1306 #define IR_FREQ (36000)
1307 #endif
1308 
1309 // IR coms
1310 #ifndef IR_OUT
1311 #define IR_OUT (24)
1312 #endif
1313 
1314 #ifndef IR_IN
1315 #define IR_IN (23)
1316 #endif
1317 
1318 // OLED connections
1319 #ifndef OLED_DAT
1320 #define OLED_DAT (22)
1321 #endif
1322 
1323 #ifndef OLED_CLK
1324 #define OLED_CLK (21)
1325 #endif
1326 
1327 #ifndef OLED_DC
1328 #define OLED_DC (20)
1329 #endif
1330 
1331 #ifndef OLED_RST
1332 #define OLED_RST (19)
1333 #endif
1334 
1335 #ifndef OLED_CS
1336 #define OLED_CS (18)
1337 #endif
1338 
1339 // composite video (J503)
1340 #ifndef TV_DAC2
1341 #define TV_DAC2 (14)
1342 #endif
1343 
1344 #ifndef TV_DAC1
1345 #define TV_DAC1 (13)
1346 #endif
1347 
1348 #ifndef TV_DAC0
1349 #define TV_DAC0 (12)
1350 #endif
1351 // audio (J503)
1352 #ifndef AUD_RT
1353 #define AUD_RT (10)
1354 #endif
1355 
1356 #ifndef AUD_LF
1357 #define AUD_LF (9)
1358 #endif
1359 // blue led charlieplex pins
1360 #ifndef BLU_CP2
1361 #define BLU_CP2 (8)
1362 #endif
1363 // define BLU_CP2 (3)
1364 #ifndef BLU_CP1
1365 #define BLU_CP1 (7)
1366 #endif
1367 // define BLU_CP1 (2)
1368 #ifndef BLU_CP0
1369 #define BLU_CP0 (6)
1370 #endif
1371 // define BLU_CP0 (1)
1372 // rgb led charlieplex pins
1373 #ifndef RGB_CP2
1374 #define RGB_CP2 (3)
1375 #endif
1376 // define RGB_CP2 (8)
1377 #ifndef RGB_CP1
1378 #define RGB_CP1 (2)
1379 #endif
1380 // define RGB_CP1 (7)
1381 #ifndef RGB_CP0
1382 #define RGB_CP0 (1)
1383 #endif
1384 // define RGB_CP0 (6)
1385 
1386 /* buttons masks */
1387 // upper right
1388 #ifndef PB0_MASK
1389 #define PB0_MASK (1)
1390 #endif
1391 // middle right
1392 #ifndef PB1_MASK
1393 #define PB1_MASK (2)
1394 #endif
1395 // lower right
1396 #ifndef PB2_MASK
1397 #define PB2_MASK (4)
1398 #endif
1399 // lower left
1400 #ifndef PB3_MASK
1401 #define PB3_MASK (8)
1402 #endif
1403 // middle left
1404 #ifndef PB4_MASK
1405 #define PB4_MASK (16)
1406 #endif
1407 // upper left
1408 #ifndef PB5_MASK
1409 #define PB5_MASK (32)
1410 #endif
1411 // open source logo
1412 #ifndef PB6_MASK
1413 #define PB6_MASK (64)
1414 #endif
1415 
1416 #ifndef OFF_MASK
1417 #define OFF_MASK ((PB5_MASK | PB0_MASK))
1418 #endif
1419 
1420 #ifndef STX //serial framing bytes
1421 #define STX 2 //serial framing bytes
1422 #endif
1423 
1424 #ifndef ETX
1425 #define ETX 3
1426 #endif
1427 
1428 #ifndef LCD_BUFFER_SIZE_BOTH_TYPES
1429 #define LCD_BUFFER_SIZE_BOTH_TYPES (1024)
1430 #endif
1431 
1432 #ifndef SSD1306_SWITCHCAPVCC
1433 #define SSD1306_SWITCHCAPVCC (2)
1434 #endif
1435 
1436 #ifndef TYPE_128X32
1437 #define TYPE_128X32 (32)
1438 #endif
1439 
1440 #ifndef TYPE_128X64
1441 #define TYPE_128X64 (64)
1442 #endif
1443 
1444 #ifndef EE_BADGE_DATA_START
1445 #define EE_BADGE_DATA_START 32768
1446 #endif
1447 
1448 #ifndef EE_BADGE_DATA_END
1449 #define EE_BADGE_DATA_END 65536 - 4
1450 #endif
1451 
1452 void init_MMA7660FC(void);
1453 void ee_init(void);
1454 
1455 
1456 
1457 // accelerometer interrupt in
1458 #ifndef ACC_INT
1459 #define ACC_INT (4)
1460 #endif
1461 
1462 #ifndef XOUT
1463 #define XOUT 0
1464 #endif
1465 
1466 #ifndef YOUT
1467 #define YOUT 1
1468 #endif
1469 
1470 #ifndef ZOUT
1471 #define ZOUT 2
1472 #endif
1473 
1474 #ifndef TILT
1475 #define TILT 3
1476 #endif
1477 
1478 #ifndef SRST
1479 #define SRST 4
1480 #endif
1481 
1482 #ifndef SPCNT
1483 #define SPCNT 5
1484 #endif
1485 
1486 #ifndef INTSU
1487 #define INTSU 6
1488 #endif
1489 
1490 #ifndef MODE
1491 #define MODE 7
1492 #endif
1493 
1494 #ifndef SR
1495 #define SR 8
1496 #endif
1497 
1498 #ifndef PDET
1499 #define PDET 9
1500 #endif
1501 
1502 #ifndef PD
1503 #define PD 10
1504 #endif
1505 
1506 #ifndef MMA7660_I2C
1507 #define MMA7660_I2C 0b1001100
1508 #endif
1509 
1510 #ifndef ALERT_BIT
1511 #define ALERT_BIT 0b01000000 //0x40
1512 #endif
1513 
1514 #ifndef ALERT_XYZT
1515 #define ALERT_XYZT 0x40404040
1516 #endif
1517 
1518 #ifndef BUF_SIZE
1519 #define BUF_SIZE (128)
1520 #endif
1521 
1522 #ifndef BUF_MASK
1523 #define BUF_MASK ((BUF_SIZE - 1))
1524 #endif
1525 
1526 typedef struct jm_ir_hdserial {
1527 // cog flag/id
1528  volatile int32_t cog;
1529 // rx head index
1530  volatile int32_t rxhead;
1531 // rx tail index
1532  volatile int32_t rxtail;
1533 // hub address of rxbuf
1534  volatile int32_t rxhub;
1535 // tx head index
1536  volatile int32_t txhead;
1537 // tx tail index
1538  volatile int32_t txtail;
1539 // hub address of txbuf
1540  volatile int32_t txhub;
1541 // rx pin (in)
1542  volatile int32_t rxpin;
1543 // tx pin (out)
1544  volatile int32_t txpin;
1545 // bit timing (ticks)
1546  volatile int32_t bitticks;
1547 // ctrx setup for freq
1548  volatile int32_t frsetup;
1549 // rx and tx buffers
1550  volatile uint8_t rxbuf[BUF_SIZE];
1551  volatile uint8_t txbuf[BUF_SIZE];
1552 } jm_ir_hdserial;
1553 
1554 
1555 
1556 //define TYPE_128X32 (32)
1557 //define TYPE_128X64 (64)
1558 #ifndef SSD1306_LCDWIDTH
1559 #define SSD1306_LCDWIDTH (128)
1560 #endif
1561 
1562 #ifndef SSD1306_LCDHEIGHT32
1563 #define SSD1306_LCDHEIGHT32 (32)
1564 #endif
1565 
1566 #ifndef SSD1306_LCDHEIGHT64
1567 #define SSD1306_LCDHEIGHT64 (64)
1568 #endif
1569 
1570 #ifndef SSD1306_LCDCHARMAX
1571 #define SSD1306_LCDCHARMAX (8)
1572 #endif
1573 
1574 #ifndef SSD1306_SETCONTRAST
1575 #define SSD1306_SETCONTRAST (129)
1576 #endif
1577 
1578 #ifndef SSD1306_DISPLAYALLON_RESUME
1579 #define SSD1306_DISPLAYALLON_RESUME (164)
1580 #endif
1581 
1582 #ifndef SSD1306_DISPLAYALLON
1583 #define SSD1306_DISPLAYALLON (165)
1584 #endif
1585 
1586 #ifndef SSD1306_NORMALDISPLAY
1587 #define SSD1306_NORMALDISPLAY (166)
1588 #endif
1589 
1590 #ifndef SSD1306_INVERTDISPLAY
1591 #define SSD1306_INVERTDISPLAY (167)
1592 #endif
1593 
1594 #ifndef SSD1306_DISPLAYOFF
1595 #define SSD1306_DISPLAYOFF (174)
1596 #endif
1597 
1598 #ifndef SSD1306_DISPLAYON
1599 #define SSD1306_DISPLAYON (175)
1600 #endif
1601 
1602 #ifndef SSD1306_SETDISPLAYOFFSET
1603 #define SSD1306_SETDISPLAYOFFSET (211)
1604 #endif
1605 
1606 #ifndef SSD1306_SETCOMPINS
1607 #define SSD1306_SETCOMPINS (218)
1608 #endif
1609 
1610 #ifndef SSD1306_SETVCOMDETECT
1611 #define SSD1306_SETVCOMDETECT (219)
1612 #endif
1613 
1614 #ifndef SSD1306_SETDISPLAYCLOCKDIV
1615 #define SSD1306_SETDISPLAYCLOCKDIV (213)
1616 #endif
1617 
1618 #ifndef SSD1306_SETPRECHARGE
1619 #define SSD1306_SETPRECHARGE (217)
1620 #endif
1621 
1622 #ifndef SSD1306_SETMULTIPLEX
1623 #define SSD1306_SETMULTIPLEX (168)
1624 #endif
1625 
1626 #ifndef SSD1306_SETLOWCOLUMN
1627 #define SSD1306_SETLOWCOLUMN (0)
1628 #endif
1629 
1630 #ifndef SSD1306_SETHIGHCOLUMN
1631 #define SSD1306_SETHIGHCOLUMN (16)
1632 #endif
1633 
1634 #ifndef SSD1306_SETSTARTLINE
1635 #define SSD1306_SETSTARTLINE (64)
1636 #endif
1637 
1638 #ifndef SSD1306_MEMORYMODE
1639 #define SSD1306_MEMORYMODE (32)
1640 #endif
1641 
1642 #ifndef SSD1306_COMSCANINC
1643 #define SSD1306_COMSCANINC (192)
1644 #endif
1645 
1646 #ifndef SSD1306_COMSCANDEC
1647 #define SSD1306_COMSCANDEC (200)
1648 #endif
1649 
1650 #ifndef SSD1306_SEGREMAP
1651 #define SSD1306_SEGREMAP (160)
1652 #endif
1653 
1654 #ifndef SSD1306_CHARGEPUMP
1655 #define SSD1306_CHARGEPUMP (141)
1656 #endif
1657 
1658 #ifndef SSD1306_EXTERNALVCC
1659 #define SSD1306_EXTERNALVCC (1)
1660 #endif
1661 
1662 
1663 // Scrolling #defines
1664 #ifndef SSD1306_ACTIVATE_SCROLL
1665 #define SSD1306_ACTIVATE_SCROLL (47)
1666 #endif
1667 
1668 #ifndef SSD1306_DEACTIVATE_SCROLL
1669 #define SSD1306_DEACTIVATE_SCROLL (46)
1670 #endif
1671 
1672 #ifndef SSD1306_SET_VERT_SCROLL_AREA
1673 #define SSD1306_SET_VERT_SCROLL_AREA (163)
1674 #endif
1675 
1676 #ifndef SSD1306_RIGHT_HORIZ_SCROLL
1677 #define SSD1306_RIGHT_HORIZ_SCROLL (38)
1678 #endif
1679 
1680 #ifndef SSD1306_LEFT_HORIZ_SCROLL
1681 #define SSD1306_LEFT_HORIZ_SCROLL (39)
1682 #endif
1683 
1684 #ifndef SSD1306_VERTRIGHTHORIZSCROLL
1685 #define SSD1306_VERTRIGHTHORIZSCROLL (41)
1686 #endif
1687 
1688 #ifndef SSD1306_VERTLEFTHORIZSCROLL
1689 #define SSD1306_VERTLEFTHORIZSCROLL (42)
1690 #endif
1691 
1692 #ifndef LCD_BUFFER_SIZE_BOTH_TYPES
1693 #define LCD_BUFFER_SIZE_BOTH_TYPES (1024)
1694 #endif
1695 
1696 #ifndef SSD1306_SWITCHCAPVCC
1697 #define SSD1306_SWITCHCAPVCC (2)
1698 #endif
1699 
1700 #ifndef TYPE_128X32
1701 #define TYPE_128X32 (32)
1702 #endif
1703 
1704 #ifndef TYPE_128X64
1705 #define TYPE_128X64 (64)
1706 #endif
1707 
1708 
1709 typedef volatile struct screen {
1710  volatile int cog;
1711  volatile int command;
1712  volatile int CS;
1713  volatile int DC;
1714  volatile int DATA;
1715  volatile int CLK;
1716  volatile int RST;
1717  volatile int vccstate;
1718  volatile int displayWidth;
1719  volatile int displayHeight;
1720  volatile int displayType;
1721  volatile int AutoUpdate;
1722  volatile uint8_t buffer[LCD_BUFFER_SIZE_BOTH_TYPES];
1723  volatile int charSize;
1724  volatile int crsrX;
1725  volatile int crsrY;
1726 } screen;
1727 
1728 
1729 extern uint8_t oleddat[];
1730 
1731 void screen_string8x2(char *str, int32_t len, int32_t row, int32_t col);
1732 void screen_string16x4( char *str, int len, int row, int col);
1733 void screen_char32x16( int ch, int row, int col);
1734 void screen_char7x5( int ch, int row, int col);
1735 
1736 int screen_HIGH( int Pin);
1737 int screen_LOW( int Pin);
1738 int32_t screen_swap( int32_t a, int32_t b);
1739 int screen_AutoUpdateOn( void );
1740 int screen_AutoUpdateOff( void );
1741 
1742 void ee_displayIndex(int start, int end, int increment);
1743 void stringView(char *s, int ssize);
1744 int sscan_ct(const char *str, const char *fmt, ...);
1745 int _doscanf_ct(const char* str, const char *fmt, va_list args);
1746 int ir_receive(char *s, int ssize);
1747 void ir_start(void);
1748 void ir_stop(void);
1749 void ee_badgeCheck(void);
1750 int light_start( void );
1751 int touch_start(int count, unsigned char *p_pins, int dms);
1752 
1753 int screen_GetDisplayHeight( void );
1754 int screen_GetDisplayWidth( void );
1755 int screen_GetDisplayType( void );
1756 int screen_ssd1306_Command( int thecmd);
1757 int screen_ssd1306_Data( int thedata);
1758 int screen_getSplash( void );
1759 int screen_SHIFTOUT( int Dpin, int Cpin, int CSpin, int Bits, int Value);
1760 int screen_WRITEBUFF( int Dpin, int Cpin, int CSpin, int Bits, int Addr);
1761 int screen_init( int ChipSelect, int DataCommand, int TheData, int TheClock, int Reset, int VCC_state, int Type);
1762 void screen_string8x2(char *str, int32_t len, int32_t row, int32_t col);
1763 void screen_string16x4( char *str, int len, int row, int col);
1764 
1765 int screen_getBuffer( void );
1766 int screen_start( void );
1767 int screen_stop( void );
1768 
1769 void screen_char32x16( int ch, int row, int col);
1770 void screen_char7x5( int ch, int row, int col);
1771 
1772 
1773 int get_bit(int bitNum, int val);
1774 void set_bit(int bitNum, int *val);
1775 void clear_bit(int bitNum, int *val);
1776 
1777 
1778 #ifdef __GNUC__
1779 #define INLINE__ static inline
1780 #define Yield__() __asm__ volatile( "" ::: "memory" )
1781 #define PostEffect__(X, Y) __extension__({ int32_t tmp__ = (X); (X) = (Y); tmp__; })
1782 #else
1783 #define INLINE__ static
1784 static int32_t tmp__;
1785 #define PostEffect__(X, Y) (tmp__ = (X), (X) = (Y), tmp__)
1786 #define Yield__()
1787 #define waitcnt(n) _waitcnt(n)
1788 #define coginit(id, code, par) _coginit((unsigned)(par)>>2, (unsigned)(code)>>2, id)
1789 #define cognew(code, par) coginit(0x8, (code), (par))
1790 #define cogstop(i) _cogstop(i)
1791 #endif
1792 
1793 INLINE__ int32_t Min__(int32_t a, int32_t b) { return a < b ? a : b; }
1794 INLINE__ int32_t Max__(int32_t a, int32_t b) { return a > b ? a : b; }
1795 INLINE__ int32_t Shr__(uint32_t a, uint32_t b) { return (a>>b); }
1796 INLINE__ int32_t Rotl__(uint32_t a, uint32_t b) { return (a<<b) | (a>>(32-b)); }
1797 INLINE__ int32_t Rotr__(uint32_t a, uint32_t b) { return (a>>b) | (a<<(32-b)); }
1798 INLINE__ int32_t Lookup__(int32_t x, int32_t b, int32_t a[], int32_t n) { int32_t i = (x)-(b); return ((unsigned)i >= n) ? 0 : (a)[i]; }
1799 
1800 
1805 #endif // DOXYGEN_SHOULD_SKIP_THIS
1806 
1807 
1808 #if defined(__cplusplus)
1809 }
1810 #endif
1811 /* __cplusplus */
1812 #endif
1813 /* SIMPLETOOLS_H */
1814 
1815 
1816 /*
1817 #ifdef __GNUC__
1818 #define INLINE__ static inline
1819 #define PostEffect__(X, Y) __extension__({ int tmp__ = (X); (X) = (Y); tmp__; })
1820 #else
1821 #define INLINE__ static
1822 static int tmp__;
1823 #define PostEffect__(X, Y) (tmp__ = (X), (X) = (Y), tmp__)
1824 #define waitcnt(n) _waitcnt(n)
1825 #define coginit(id, code, par) _coginit((unsigned)(par)>>2, (unsigned)(code)>>2, id)
1826 #define cognew(code, par) coginit(0x8, (code), (par))
1827 #define cogstop(i) _cogstop(i)
1828 #endif
1829 
1830 __asm__ volatile( " .global __clkfreqval\n" );
1831 __asm__ volatile( " __clkfreqval = 0x4c4b400\n" );
1832 __asm__ volatile( " .global __clkmodeval\n" );
1833 __asm__ volatile( " __clkmodeval = 0x6f\n" );
1834 */
1835 
1836 
1837 /*
1838  TERMS OF USE: MIT License
1839 
1840  Permission is hereby granted, free of charge, to any person obtaining a
1841  copy of this software and associated documentation files (the "Software"),
1842  to deal in the Software without restriction, including without limitation
1843  the rights to use, copy, modify, merge, publish, distribute, sublicense,
1844  and/or sell copies of the Software, and to permit persons to whom the
1845  Software is furnished to do so, subject to the following conditions:
1846 
1847  The above copyright notice and this permission notice shall be included in
1848  all copies or substantial portions of the Software.
1849 
1850  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1851  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1852  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1853  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1854  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1855  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1856  DEALINGS IN THE SOFTWARE.
1857 */
1858 
1859 
float ee_readFloat32(int addr)
Fetch a 32-bit precision floating point value from a certain address in the Propeller Chip&#39;s dedicate...
int receive(char *s)
Receive a character string from another badge.
int accel(int axis)
Measures acceleration and tilt on one of 3 axes (AX, AY, or AZ) in terms of centigravity (cg) units...
void circleFilled(int x0, int y0, int r, int c)
Plot a filled circle on the oLED screen.
void contacts_eraseAll()
Erases user portion of EEPROM by placing 255 in each cell. This erasure affects addresses 32768 throu...
void string(char *str)
Display a character string on the oLED display.
void leds(int bits)
Sets the on/off states of the 6 blue LEDs with a number that contains six binary 1/0 digits...
void irclear(void)
Clear the infrared send/receive buffers. The most common use of this function is to clear any stray m...
void rgb(int side, int color)
Sets the color of the left or right RGB LED. Examples: rgb(L, RED) makes the left RGB LED glow red...
int screen_scrollLeftDiag(int scrollStart, int scrollStop)
Cause the screen to scroll diagonally to the left with screen_scrollLeftDiag(0, 15).
void ee_writeStr(char *s, int n, int addr)
Store a string of byte values starting at a certain address in the Propeller Chip&#39;s dedicated EEPROM...
void boxFilled(int x0, int y0, int x1, int y1, int c)
Plot a filled box on the oLED screen.
int buttons(void)
Gets the states of all seven touch buttons, and returns them in a value with 1s and 0s that correspon...
int clear(void)
Clear the display.
int stored(char *s)
Check if a string has already been stored in EEPROM. Example: if(!stored("abcd")) store("abcd");...
void ee_writeShort(short value, int addr)
Store a short value at a certain address in the Propeller Chip&#39;s dedicated EEPROM. A short value occupies two bytes, so the next value should be stored at an address value that&#39;s two bytes higher.
int screen_scrollRightDiag(int scrollStart, int scrollStop)
Cause the screen to scroll diagonally to the right with screen_scrollRightDiag(0, 15)...
void screen_auto(int state)
Cause function calls like oledprint, point, and others to appear immediately after the function is ca...
void cursor(int col, int row)
Position the cursor to a certain column and row for printing text on the oLED display. Column can be 0 to 7 and row can be 0 or 1 in default LARGE text mode. In SMALL text mode, column can be 0 to 31, and row can be 0 to 7.
int screen_scrollRight(int scrollStart, int scrollStop)
Cause the screen to scroll to the right with screen_scrollRight(0, 15).
void contacts_setStartAddr(int address)
Set the start address of the contacts. This can be used to reserve some user EEPROM space for other p...
int irprint(const char *fmt,...)
Use to store transmit strings to another badge in a manner similar to displaying combinations of stri...
int eescan(int recIdx, const char *fmt,...)
Use to retrieve strings to EEPROM in a manner similar to retrieving strings that represent combinatio...
void text_size(int size)
Set the text size to either 32x16 pixel (LARGE) or 7x5 (SMALL) characters. Examples: text_size(LARGE)...
int button(int pad)
Gets the state of a touch button (1) pressed, (0) not pressed. Numbering {6, 5, 4, 3, 2, 1, 0} maps the pads by {OSH, P17, P16, P15, P25, P26, P27}. Example: int state = button(3); If state stores 1, it means the pad next to the P15 label is pressed. If it instead stores 0, the button is not pressed.
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...
int eeprinted(const char *fmt,...)
Can be called before storing a record with eeprint. Example: if(!eeprinted("Hello EEPROM") eeprint("H...
void ir_send(char *s, int ssize)
Transmits a string with a specified number of characters over IR.
short ee_readShort(int addr)
Get a short value from a certain address in the Propeller Chip&#39;s dedicated EEPROM. If you are fetching several short values, make sure to add 2 to the addr value with each successive call.
void invert(int i)
Invert (or not) the pixel colors in the display. Use invert(0) for white pixels on a black background...
void point(int x, int y, int color)
Plot a point on the oLED screen.
void line(int x0, int y0, int x1, int y1, int c)
Plot a line on the oLED screen.
void contacts_displayAll()
Display all contacts in SimpleIDE Terminal.
void triangle(int x0, int y0, int x1, int y1, int x2, int y2, int c)
Plot a triangle on the oLED screen.
void rgbs(int colorL, int colorR)
Set both RGB LED colors with one function call. See rgb function for color options.
void dev_ee_show(int byteCount, int address)
Display EEPROM contents as a combination of printable characters and numeric values (when not printab...
void accels(int *x, int *y, int *z)
Measures acceleration and tilt on all 3 axes (x, y, and z) in terms of centigravity (cg) units...
int screen_scrollLeft(int scrollStart, int scrollStop)
Cause the screen to scroll to the left with screen_scrollLeft(0, 15).
int store(char *contact)
Store a character string of up to 128 characters to EEPROM. Example: char s[] = "abcd"; store(s);...
int irscan(const char *fmt,...)
Use to receive strings over IR from another badge in a manner similar to retrieving strings that repr...
int ir_receive(char *s, int ssize)
Receive a string with a specified maxiumum number of characters over IR.
void ee_writeFloat32(float fpVal, int addr)
Store a 32-bit precision floating point value at a certain address in the Propeller Chip&#39;s dedicated ...
void screen_image(char *imgaddr)
Display an image using an array holding an image generated by software that is compatible with the sc...
void ee_writeInt(int value, int addr)
Store an int value at a certain address in the Propeller Chip&#39;s dedicated EEPROM. An int value occupi...
int contacts_count()
Find out how many contacts are currently stored in EEPROM. This is useful for setting up a loop to fe...
int eeprint(const char *fmt,...)
Use to store strings to EEPROM in a manner similar to displaying combinations of strings and variable...
void rotate180()
Rotate the screen image 180 degrees. See 05 Display Upside- Down.side for example.
int badge_setup(void)
Set up all available badge drivers. Call this function at the start of any given program to allow acc...
void circle(int x0, int y0, int r, int c)
Plot a circle on the oLED screen.
int accel_shaken(void)
Check if accelerometer was shaken recently, within the last half second.
int screen_getAuto()
Check if function calls like oledprint, point, and others are set to appear (1) immediately after the...
char * ee_readStr(unsigned char *s, int n, int addr)
Fetch a string of byte values starting at a certain address in Propeller Chip&#39;s dedicated EEPROM...
void retrieve(char *contact, int recIdx)
Copy string with a certain index number from EEPROM to a character array.
void led(int n, int state)
Set a blue LED (from 0 to 5) to a state (ON or OFF). Examples: led(1, ON) turns the blue LED next to ...
int screen_update(void)
Manually update the screen image after. Typically used after multiple oLED function calls after scree...
void triangleFilled(int x0, int y0, int x1, int y1, int x2, int y2, int c)
Plot a filled triangle on the oLED screen.
char ee_readByte(int addr)
Get a byte value from a certain address in the Propeller Chip&#39;s dedicated EEPROM. ...
int ee_readInt(int addr)
Get an int value from a certain address in the Propeller Chip&#39;s dedicated EEPROM. If you are fetching...
void box(int x0, int y0, int x1, int y1, int c)
Plot a box on the oLED screen.
void ee_writeByte(unsigned char value, int addr)
Store a byte value at a certain address in the Propeller Chip&#39;s dedicated EEPROM. ...
int screen_scrollStop(void)
Stop screen scrolling action.
int oledprint(const char *fmt,...)
Use to display strings on the oLED display in a manner similar to displaying combinations of strings ...
int send(char *s)
Send a character string to another badge. Example: char s[] = "Hello other badge"; send(s);...