badgetools library
v0.51.1
Collection of convenience functions for the Parallax eBadge
|
This library provides convenient functions for a variety of Parallax eBadge operations. More...
#include "simpletools.h"
#include <stdint.h>
Go to the source code of this file.
Macros | |
LEDs | |
#define | ON 1 |
For turning blue LEDs on. Example: led(0, ON) would turn the LED by the P27 label on. | |
#define | OFF 0 |
For turning off blue or RGB LEDs. Examples: led(1, OFF), would turn the LED by the P26 label off. rgb(L, OFF) would turn off the left rgb LED, and rgbs(OFF, OFF) would turn off the left and right RGB LEDs. | |
RGB LEDs | |
#define | L 1 |
For selecting the left of the two RGB LEDs. Example: rgb(L, RED) would set the left RGB LED to the color red. | |
#define | R 0 |
For selecting the right of the two RGB LEDs. Example: rgb(R, GREEN) would set the right RGB LED to the color green. | |
#define | BLUE (1) |
For setting an RGB LED's color to blue. Examples: rgb(L, BLUE) sets the left RGB LED blue. rgbs(BLUE, BLUE) would set both RGB LEDs blue. | |
#define | GREEN (2) |
For setting an RGB LED's color to green. Examples: rgb(R, GREEN) sets the right RGB LED to green. rgbs(GREEN, GREEN) would set both RGB LEDs green. | |
#define | CYAN (3) |
For setting an RGB LED's color to cyan. Examples: rgb(L, CYAN) sets the left RGB LED to cyan. rgbs(CYAN, CYAN) would set both RGB LEDs cyan. | |
#define | RED (4) |
For setting an RGB LED's color to red. Examples: rgb(R, RED) sets the right RGB LED red. rgbs(CYAN, CYAN) would set both RGB LEDs red. | |
#define | MAGENTA (5) |
For setting an RGB LED's color to magenta. Examples: rgb(L, MAGENTA) sets the left RGB LED magenta. rgbs(MAGENTA, MAGENTA) would set both RGB LEDs magenta. | |
#define | YELLOW (6) |
For setting an RGB LED's color to yellow. Examples: rgb(L, YELLOW) sets the left RGB LED yellow. rgbs(YELLOW, YELLOW) would set both RGB LEDs yellow. | |
#define | WHITE (7) |
For setting an RGB LED's color to white. Examples: rgb(L, WHITE) sets the left RGB LED white. rgbs(WHITE, WHITE) would set both RGB LEDs white. | |
Functions | |
int | badge_setup (void) |
Set up all available badge drivers. Call this function at the start of any given program to allow access to ensure that the rest of this library's functions work properly. More... | |
LED Lights | |
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 the P26 label on. led(3, OFF) turns the blue LED by the P15 label off. More... | |
void | leds (int bits) |
Sets the on/off states of the 6 blue LEDs with a number that contains six binary 1/0 digits. How does the 6 digit binary number work? Count the number of digits from the right, and that's the led number used in the led(int n, int state) function. For example, leds(0b110010) is equivalent to these six led calls: led(5, ON); led(4, ON); led(3, OFF); led(2, OFF); led(1, ON); led(0, OFF). More... | |
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. rgb(R, GREEN) makes the right one glow green. Color options include BLUE, GREEN, CYAN, YELLOW, RED, MAGENTA, WHITE. You can also use OFF to make a light that is glowing turn off. The numeric values of these are listed in Macros -> RGB LEDs. More... | |
void | rgbs (int colorL, int colorR) |
Set both RGB LED colors with one function call. See rgb function for color options. More... | |
Touch Buttons | |
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. More... | |
int | buttons (void) |
Gets the states of all seven touch buttons, and returns them in a value with 1s and 0s that correspond to each touch button. Example: int states = buttons(); If states stores 0b1110010, it means: {OSH-pressed, P17-pressed, P16-pressed, P15-not pressed, P25-not pressed, P26-pressed, P27-not pressed}. More... | |
Contact Storage | |
int | store (char *contact) |
Store a character string of up to 128 characters to EEPROM. Example: char s[] = "abcd"; store(s);. More... | |
int | stored (char *s) |
Check if a string has already been stored in EEPROM. Example: if(!stored("abcd")) store("abcd");. More... | |
void | retrieve (char *contact, int recIdx) |
Copy string with a certain index number from EEPROM to a character array. More... | |
int | eeprint (const char *fmt,...) |
Use to store strings to EEPROM in a manner similar to displaying combinations of strings and variables in the SimpleIDE terminal with the print function. Examples: eeprint("Hello EEPROM"); float f = PI; int n = 4s; char s[] = "PI and answer to universe"; eeprint("%1.3f\n%03d\n
%30s\n", f, n, s); // Result to EEPROM: "Hello EEPROM"[0]"3.141"[10]"042" [10]"PI and answer to universe"[10][0]. This information can be conveniently retrieved back from EEPROM and placed in variables with the eescan function. More... | |
int | eeprinted (const char *fmt,...) |
Can be called before storing a record with eeprint. Example: if(!eeprinted("Hello EEPROM") eeprint("Hello EEPROM");. More... | |
int | eescan (int recIdx, const char *fmt,...) |
Use to retrieve strings to EEPROM in a manner similar to retrieving strings that represent combinations of strings and variables from the SimpleIDE terminal with the scan function. Examples: This example will retrieve the what the eeprint examples stored in EEPROM: char s1[14]; eescan(1, "%s", s1); float f; int n; char s2[30]; eescan("%f%d%s", f, n, s2); // Result: s1 = "Hello EEPROM", f = 3.141, n = 42, s2 = "PI and
answer to universe". More... | |
int | contacts_count () |
Find out how many contacts are currently stored in EEPROM. This is useful for setting up a loop to fetch all contacts. More... | |
void | contacts_eraseAll () |
Erases user portion of EEPROM by placing 255 in each cell. This erasure affects addresses 32768 through 65535. | |
void | contacts_displayAll () |
Display all contacts in SimpleIDE Terminal. | |
void | contacts_setStartAddr (int address) |
Set the start address of the contacts. This can be used to reserve some user EEPROM space for other purposes before the start of the contacts. More... | |
void | ee_writeByte (unsigned char value, int addr) |
Store a byte value at a certain address in the Propeller Chip's dedicated EEPROM. More... | |
char | ee_readByte (int addr) |
Get a byte value from a certain address in the Propeller Chip's dedicated EEPROM. More... | |
void | ee_writeShort (short value, int addr) |
Store a short value at a certain address in the Propeller Chip's dedicated EEPROM. A short value occupies two bytes, so the next value should be stored at an address value that's two bytes higher. More... | |
short | ee_readShort (int addr) |
Get a short value from a certain address in the Propeller Chip's dedicated EEPROM. If you are fetching several short values, make sure to add 2 to the addr value with each successive call. More... | |
void | ee_writeInt (int value, int addr) |
Store an int value at a certain address in the Propeller Chip's dedicated EEPROM. An int value occupies four bytes, so the next value should be stored at an address value that's four bytes higher. More... | |
int | ee_readInt (int addr) |
Get an int value from a certain address in the Propeller Chip's dedicated EEPROM. If you are fetching several int values, make sure to add 4 to the addr value with each successive call. More... | |
void | ee_writeFloat32 (float fpVal, int addr) |
Store a 32-bit precision floating point value at a certain address in the Propeller Chip's dedicated EEPROM. A 32-bit value occupies four bytes so if you are storing values in a sequence, make sure to add 4 to each addr parameter value. More... | |
float | ee_readFloat32 (int addr) |
Fetch a 32-bit precision floating point value from a certain address in the Propeller Chip's dedicated EEPROM. A 32-bit value occupies four bytes so if you are fetching values in a sequence, make sure to add 4 to each addr parameter value. More... | |
void | ee_writeStr (char *s, int n, int addr) |
Store a string of byte values starting at a certain address in the Propeller Chip's dedicated EEPROM. More... | |
char * | ee_readStr (unsigned char *s, int n, int addr) |
Fetch a string of byte values starting at a certain address in Propeller Chip's dedicated EEPROM. More... | |
Infrared Communication | |
int | send (char *s) |
Send a character string to another badge. Example: char s[] = "Hello other badge"; send(s);. More... | |
int | receive (char *s) |
Receive a character string from another badge. More... | |
void | irclear (void) |
Clear the infrared send/receive buffers. The most common use of this function is to clear any stray messages that my have arrived before receiving a contact from another badge. | |
int | irprint (const char *fmt,...) |
Use to store transmit strings to another badge in a manner similar to displaying combinations of strings and variables in the SimpleIDE terminal with the print function. Examples: irprint("Hello eBadge"); float f = PI; int n = 4s; char s[] = "PI and answer to universe"; irprint("%1.3f\n%03d\n %30s\n", f, n, s); // Result to other badge: "Hello EEPROM"[0]"3.141"[10]"042"[10]"PI and answer to universe"[10][0]. This information can be conveniently received by the other badge using the irscan function. More... | |
int | irscan (const char *fmt,...) |
Use to receive strings over IR from another badge in a manner similar to retrieving strings that represent combinations of strings and variables from the SimpleIDE terminal with the scan function. Examples: This example will retrieve what the irprint examples transmitted to the other badge: char s1[14]; eescan(1, "%s", s1); float f; int n; char s2[30]; eescan("%f%d%s", f, n, s2); // Result: s1 = "Hello EEPROM", f = 3.141, n = 42, s2 = "PI and
answer to universe". More... | |
void | ir_send (char *s, int ssize) |
Transmits a string with a specified number of characters over IR. More... | |
int | ir_receive (char *s, int ssize) |
Receive a string with a specified maxiumum number of characters over IR. More... | |
oLED Screen Display (Basics) | |
int | oledprint (const char *fmt,...) |
Use to display strings on the oLED display in a manner similar to displaying combinations of strings and variables in the SimpleIDE terminal with the print function. Example: oledprint("Hello!!!"); text_size(SMALL); cursor(0, 4); float f = PI; int n = 4s; char s[] = "PI and Universe"; oledprint("%1.3f, %03d\n%30s", f, n, s); // Result to oLED display: Upper half large print by default - Hello!!! Small print line 4: 1.414, 042 Line 5 "PI and Universe". More... | |
void | text_size (int size) |
Set the text size to either 32x16 pixel (LARGE) or 7x5 (SMALL) characters. Examples: text_size(LARGE);...text_size(SMALL)...text_size(LARGE). More... | |
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. More... | |
void | string (char *str) |
Display a character string on the oLED display. More... | |
int | clear (void) |
Clear the display. More... | |
void | invert (int i) |
Invert (or not) the pixel colors in the display. Use invert(0) for white pixels on a black background, or invert(1) for black pixels on a white background. | |
void | point (int x, int y, int color) |
Plot a point on the oLED screen. More... | |
void | line (int x0, int y0, int x1, int y1, int c) |
Plot a line on the oLED screen. More... | |
void | box (int x0, int y0, int x1, int y1, int c) |
Plot a box on the oLED screen. More... | |
void | boxFilled (int x0, int y0, int x1, int y1, int c) |
Plot a filled box on the oLED screen. More... | |
void | triangle (int x0, int y0, int x1, int y1, int x2, int y2, int c) |
Plot a triangle on the oLED screen. More... | |
void | triangleFilled (int x0, int y0, int x1, int y1, int x2, int y2, int c) |
Plot a filled triangle on the oLED screen. More... | |
void | circle (int x0, int y0, int r, int c) |
Plot a circle on the oLED screen. More... | |
void | circleFilled (int x0, int y0, int r, int c) |
Plot a filled circle on the oLED screen. More... | |
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.side for example. More... | |
void | rotate180 () |
Rotate the screen image 180 degrees. See 05 Display Upside- Down.side for example. | |
void | screen_auto (int state) |
Cause function calls like oledprint, point, and others to appear immediately after the function is called with screen_auto(1). To make multiple changes before manually updating with a call to screen_update, use screen_auto(0). See 04 Screen Auto ON OFF.side for example. More... | |
int | screen_getAuto () |
Check if function calls like oledprint, point, and others are set to appear (1) immediately after the function is called or (0) if multiple changes are made before manually updating with a call to screen_update. More... | |
int | screen_update (void) |
Manually update the screen image after. Typically used after multiple oLED function calls after screen_auto(0). See 04 Screen Auto ON OFF.side for example. More... | |
oLED Screen Display (Intermediate) | |
int | screen_scrollRight (int scrollStart, int scrollStop) |
Cause the screen to scroll to the right with screen_scrollRight(0, 15). More... | |
int | screen_scrollLeft (int scrollStart, int scrollStop) |
Cause the screen to scroll to the left with screen_scrollLeft(0, 15). More... | |
int | screen_scrollRightDiag (int scrollStart, int scrollStop) |
Cause the screen to scroll diagonally to the right with screen_scrollRightDiag(0, 15). More... | |
int | screen_scrollLeftDiag (int scrollStart, int scrollStop) |
Cause the screen to scroll diagonally to the left with screen_scrollLeftDiag(0, 15). More... | |
int | screen_scrollStop (void) |
Stop screen scrolling action. More... | |
void | screen_image (char *imgaddr) |
Display an image using an array holding an image generated by software that is compatible with the screen's scanning. See 12 Image to Display.side for an example. More... | |
Misc | |
void | dev_ee_show (int byteCount, int address) |
Display EEPROM contents as a combination of printable characters and numeric values (when not printable) in square brackets [], See 02 View First and Last 64 Bytes with Terminal.side for example. More... | |
Accelerometer | |
#define | SCR_BLACK (0) |
Sets an oLED screen pixel to black. Example: point(27, 35, SCR_BLACK) sets a pixel 27 from the right and 35 down to black. | |
#define | SCR_WHITE (1) |
Sets an oLED screen pixel to white. Example: point(100, 50, SCR_WHITE) sets a pixel 100 from the right and 50 down to white. | |
#define | SCR_XOR (3) |
Applies XOR operation to pixels in a shape. Example: shape(frog, XOR, 36, 12, 30, 40) would invert the pixels in the frog shape array. the black pixels would be made white and vice-versa. | |
#define | LARGE 1 |
For setting oLED character size to 32x16 pixels. Example: text_size(LARGE). | |
#define | SMALL 0 |
For setting oLED character size to 7x5 pixels. Example: text_size(SMALL). | |
#define | AY 0 |
For choosing the accelerometer's y-axis. Example accel(AY) returns the component of the earth's gravitational field acting on the accelerometer's y-axis. | |
#define | AX 1 |
For choosing the accelerometer's x-axis. Example accel(AX) returns the component of the earth's gravitational field acting on the accelerometer's x-axis. | |
#define | AZ 2 |
For choosing the accelerometer's z-axis. Example accel(AZ) returns the component of the earth's gravitational field acting on the accelerometer's z-axis. | |
int | accel (int axis) |
Measures acceleration and tilt on one of 3 axes (AX, AY, or AZ) in terms of centigravity (cg) units, which is 100ths of 1 gravity (1 g). With the badge laying flat on a table, the AX is left/right, AY is forward/backward, and AZ is up/down. Example: int x = accel(AX) copies the accelerometer measurement into the x variable. The result will be 0 if held flat, and could go as high as +100 if held on its left edge, or -100 if held on its right edge. Note, the accelerometer's actual resolution is in 64ths of a 1 g. More... | |
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, which is 100ths of 1 gravity (1 g). More... | |
int | accel_shaken (void) |
Check if accelerometer was shaken recently, within the last half second. More... | |
This library provides convenient functions for a variety of Parallax eBadge operations.
Note: This is the early adopter version of a library that is fairly new and still a work-in-progress. If you find what you feel are errors or omissions that should be addressed in an upcoming revision, please email edito. r@pa ralla x.co m
To-do:
Definition in file badgetools.h.
int accel | ( | int | axis | ) |
Measures acceleration and tilt on one of 3 axes (AX, AY, or AZ) in terms of centigravity (cg) units, which is 100ths of 1 gravity (1 g). With the badge laying flat on a table, the AX is left/right, AY is forward/backward, and AZ is up/down. Example: int x = accel(AX) copies the accelerometer measurement into the x variable. The result will be 0 if held flat, and could go as high as +100 if held on its left edge, or -100 if held on its right edge. Note, the accelerometer's actual resolution is in 64ths of a 1 g.
axis | The AX, AY, or AZ sensing axis. |
int accel_shaken | ( | void | ) |
Check if accelerometer was shaken recently, within the last half second.
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, which is 100ths of 1 gravity (1 g).
*x | Address of the variable for storing the x-axis measurement. |
*y | Address of the variable for storing the y-axis measurement. |
*z | Address of the variable for storing the z-axis measurement. |
int badge_setup | ( | void | ) |
Set up all available badge drivers. Call this function at the start of any given program to allow access to ensure that the rest of this library's functions work properly.
A call to this function sets up these badge subsystems: oLED display, LED, RGB LED, touch buttons, accelerometer, infrared communication, and EEPROM storage. Example badge_setup().
void box | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
int | c | ||
) |
Plot a box on the oLED screen.
x0 | The x coordinate of one corner of the box. Measured as a number of pixels from left side of screen. The value increases from 0 (left) to 127 (right). |
y0 | The y coordinate of one corner of the box. Measured as a number of pixels from the top of the screen. The value increases from 0 (top) to 63 (bottom). |
x1 | The x coordinate of a corner diagonal from the first corner. |
y1 | The y coordinate of the corner diagonal from the first corner. |
c | The pixel color 1 for white, 0 for black. |
void boxFilled | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
int | c | ||
) |
Plot a filled box on the oLED screen.
x0 | The x coordinate of one corner of the box. Measured as a number of pixels from left side of screen. The value increases from 0 (left) to 127 (right). |
y0 | The y coordinate of one corner of the box. Measured as a number of pixels from the top of the screen. The value increases from 0 (top) to 63 (bottom). |
x1 | The x coordinate of a corner diagonal from the first corner. |
y1 | The y coordinate of the corner diagonal from the first corner. |
c | The pixel color 1 for white, 0 for black. |
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.
int buttons | ( | void | ) |
Gets the states of all seven touch buttons, and returns them in a value with 1s and 0s that correspond to each touch button. Example: int states = buttons(); If states stores 0b1110010, it means: {OSH-pressed, P17-pressed, P16-pressed, P15-not pressed, P25-not pressed, P26-pressed, P27-not pressed}.
void circle | ( | int | x0, |
int | y0, | ||
int | r, | ||
int | c | ||
) |
Plot a circle on the oLED screen.
x0 | The x coordinate of the center of the circle. Measured as a number of pixels from left side of screen. The value increases from 0 (left) to 127 (right). |
y0 | The y coordinate of the center of the circle. Measured as a number of pixels from the top of the screen. The value increases from 0 (top) to 63 (bottom). |
r | The radius of the circle. |
c | The pixel color 1 for white, 0 for black. |
void circleFilled | ( | int | x0, |
int | y0, | ||
int | r, | ||
int | c | ||
) |
Plot a filled circle on the oLED screen.
x0 | The x coordinate of the center of the circle. Measured as a number of pixels from left side of screen. The value increases from 0 (left) to 127 (right). |
y0 | The y coordinate of the center of the circle. Measured as a number of pixels from the top of the screen. The value increases from 0 (top) to 63 (bottom). |
r | The radius of the circle. |
c | The pixel color 1 for white, 0 for black. |
int clear | ( | void | ) |
Clear the display.
Returns cursor to top-left 0, 0.
int contacts_count | ( | ) |
Find out how many contacts are currently stored in EEPROM. This is useful for setting up a loop to fetch all contacts.
void contacts_setStartAddr | ( | int | address | ) |
Set the start address of the contacts. This can be used to reserve some user EEPROM space for other purposes before the start of the contacts.
address | EEPROM starting address for contact storage. |
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.
col | the column (character position) from left. |
row | the row (line number) from top. |
void dev_ee_show | ( | int | byteCount, |
int | address | ||
) |
Display EEPROM contents as a combination of printable characters and numeric values (when not printable) in square brackets [], See 02 View First and Last 64 Bytes with Terminal.side for example.
byteCount | Number of bytes to display. |
address | Starting EEPROM address. |
char ee_readByte | ( | int | addr | ) |
Get a byte value from a certain address in the Propeller Chip's dedicated EEPROM.
addr | The EEPROM address that with the byte value that should be fetched. |
float ee_readFloat32 | ( | int | addr | ) |
Fetch a 32-bit precision floating point value from a certain address in the Propeller Chip's dedicated EEPROM. A 32-bit value occupies four bytes so if you are fetching values in a sequence, make sure to add 4 to each addr parameter value.
Make sure that the Math box is checked in the Project Manager. In Simple View, click the Show Project Manager button in SimpleIDE's bottom-left corner. Then click the Linker tab, and check the Math Lib box.
addr | The EEPROM address with the 32-bit floating point float value that should be fetched. |
int ee_readInt | ( | int | addr | ) |
Get an int value from a certain address in the Propeller Chip's dedicated EEPROM. If you are fetching several int values, make sure to add 4 to the addr value with each successive call.
addr | The EEPROM address with the int value that should be fetched. |
short ee_readShort | ( | int | addr | ) |
Get a short value from a certain address in the Propeller Chip's dedicated EEPROM. If you are fetching several short values, make sure to add 2 to the addr value with each successive call.
addr | The EEPROM address with the int value that should be fetched. |
char* ee_readStr | ( | unsigned char * | s, |
int | n, | ||
int | addr | ||
) |
Fetch a string of byte values starting at a certain address in Propeller Chip's dedicated EEPROM.
s | Address of a char array to receive the string of bytes fetched from EEPROM. |
n | The number of bytes to copy from EEPROM to the array. |
addr | The EEPROM address of the first byte in the string. |
void ee_writeByte | ( | unsigned char | value, |
int | addr | ||
) |
Store a byte value at a certain address in the Propeller Chip's dedicated EEPROM.
value | The byte value to store in EEPROM. |
addr | The EEPROM address where the value is to be stored. |
void ee_writeFloat32 | ( | float | fpVal, |
int | addr | ||
) |
Store a 32-bit precision floating point value at a certain address in the Propeller Chip's dedicated EEPROM. A 32-bit value occupies four bytes so if you are storing values in a sequence, make sure to add 4 to each addr parameter value.
Make sure that the Math box is checked in the Project Manager. In Simple View, click the Show Project Manager button in SimpleIDE's bottom-left corner. Then click the Linker tab, and check the Math Lib box.
fpVal | The 32-bit floating point float value to store in EEPROM. |
addr | The EEPROM address where the value is to be stored. |
void ee_writeInt | ( | int | value, |
int | addr | ||
) |
Store an int value at a certain address in the Propeller Chip's dedicated EEPROM. An int value occupies four bytes, so the next value should be stored at an address value that's four bytes higher.
value | The int value to store in EEPROM. |
addr | The EEPROM address where the value is to be stored. |
void ee_writeShort | ( | short | value, |
int | addr | ||
) |
Store a short value at a certain address in the Propeller Chip's dedicated EEPROM. A short value occupies two bytes, so the next value should be stored at an address value that's two bytes higher.
value | The int value to store in EEPROM. |
addr | The EEPROM address where the value is to be stored. |
void ee_writeStr | ( | char * | s, |
int | n, | ||
int | addr | ||
) |
Store a string of byte values starting at a certain address in the Propeller Chip's dedicated EEPROM.
s | Address of a char array containing the string of bytes. |
n | The number of bytes to copy from the array. |
addr | The EEPROM address of the first byte in the string. |
int eeprint | ( | const char * | fmt, |
... | |||
) |
Use to store strings to EEPROM in a manner similar to displaying combinations of strings and variables in the SimpleIDE terminal with the print function. Examples: eeprint("Hello EEPROM"); float f = PI; int n = 4s; char s[] = "PI and answer to universe"; eeprint("%1.3f\n%03d\n %30s\n", f, n, s); // Result to EEPROM: "Hello EEPROM"[0]"3.141"[10]"042" [10]"PI and answer to universe"[10][0]. This information can be conveniently retrieved back from EEPROM and placed in variables with the eescan function.
String length can be 128 or less.
*fmt | a print compatible format string. |
... | a print compatible list of arguments. |
int eeprinted | ( | const char * | fmt, |
... | |||
) |
Can be called before storing a record with eeprint. Example: if(!eeprinted("Hello EEPROM") eeprint("Hello EEPROM");.
String length can be 128 or less.
*fmt | a print compatible format string. |
... | a print compatible list of arguments. |
int eescan | ( | int | recIdx, |
const char * | fmt, | ||
... | |||
) |
Use to retrieve strings to EEPROM in a manner similar to retrieving strings that represent combinations of strings and variables from the SimpleIDE terminal with the scan function. Examples: This example will retrieve the what the eeprint examples stored in EEPROM: char s1[14]; eescan(1, "%s", s1); float f; int n; char s2[30]; eescan("%f%d%s", f, n, s2); // Result: s1 = "Hello EEPROM", f = 3.141, n = 42, s2 = "PI and answer to universe".
String length can be 128 or less.
recIdx | An integer record index value. |
*fmt | a print compatible format string. |
... | a print compatible list of arguments. |
int ir_receive | ( | char * | s, |
int | ssize | ||
) |
Receive a string with a specified maxiumum number of characters over IR.
ssize can be 128 or less.
*s | Address of the character array to store the string that was received. |
ssize | Maximmum size of the string. |
void ir_send | ( | char * | s, |
int | ssize | ||
) |
Transmits a string with a specified number of characters over IR.
ssize can be 128 or less.
*s | Address of a string to send. |
ssize | Maximmum size of the string. |
int irprint | ( | const char * | fmt, |
... | |||
) |
Use to store transmit strings to another badge in a manner similar to displaying combinations of strings and variables in the SimpleIDE terminal with the print function. Examples: irprint("Hello eBadge"); float f = PI; int n = 4s; char s[] = "PI and answer to universe"; irprint("%1.3f\n%03d\n %30s\n", f, n, s); // Result to other badge: "Hello EEPROM"[0]"3.141"[10]"042"[10]"PI and answer to universe"[10][0]. This information can be conveniently received by the other badge using the irscan function.
String length can be 128 or less.
*fmt | a print compatible format string. |
... | a print compatible list of arguments. |
int irscan | ( | const char * | fmt, |
... | |||
) |
Use to receive strings over IR from another badge in a manner similar to retrieving strings that represent combinations of strings and variables from the SimpleIDE terminal with the scan function. Examples: This example will retrieve what the irprint examples transmitted to the other badge: char s1[14]; eescan(1, "%s", s1); float f; int n; char s2[30]; eescan("%f%d%s", f, n, s2); // Result: s1 = "Hello EEPROM", f = 3.141, n = 42, s2 = "PI and answer to universe".
Total string length can be 128 or less.
*fmt | a print compatible format string. |
... | a print compatible list of arguments. |
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 the P26 label on. led(3, OFF) turns the blue LED by the P15 label off.
n | The number of the LED to turn on or off. This number can be in the 0 to 5 range. The numbers {0, 1, 2, 3, 4, 5} control the LEDs by the labels {P27, P26, P25, P15, P16, P17}. |
state | Value that turns the LED on or off. Use ON or 1 to turn the LED on, or OFF or 0 to turn the LED off. |
void leds | ( | int | bits | ) |
Sets the on/off states of the 6 blue LEDs with a number that contains six binary 1/0 digits. How does the 6 digit binary number work? Count the number of digits from the right, and that's the led number used in the led(int n, int state) function. For example, leds(0b110010) is equivalent to these six led calls: led(5, ON); led(4, ON); led(3, OFF); led(2, OFF); led(1, ON); led(0, OFF).
bits | The value with six binary digits that controls each light. A 1 in the rightmost digit does the same thing as led(0, ON), and a 0 would be the same as led(0, OFF). A 1 in the second digit from the right would do the same thing as led(1, ON), and so on... |
void line | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
int | c | ||
) |
Plot a line on the oLED screen.
x0 | The x coordinate of the first point in the line. Measured as a number of pixels from left side of screen. The value increases from 0 (left) to 127 (right). |
y0 | The y coordinate of the first point in the line. Measured as a number of pixels from the top of the screen. The value increases from 0 (top) to 63 (bottom). |
x1 | The x coordinate of the second point in the line. |
y1 | The y coordinate of the second point in the line. |
c | The pixel color 1 for white, 0 for black. |
int oledprint | ( | const char * | fmt, |
... | |||
) |
Use to display strings on the oLED display in a manner similar to displaying combinations of strings and variables in the SimpleIDE terminal with the print function. Example: oledprint("Hello!!!"); text_size(SMALL); cursor(0, 4); float f = PI; int n = 4s; char s[] = "PI and Universe"; oledprint("%1.3f, %03d\n%30s", f, n, s); // Result to oLED display: Upper half large print by default - Hello!!! Small print line 4: 1.414, 042 Line 5 "PI and Universe".
String length can be 128 or less. Word wrap is automatic if line width is exceeded.
*fmt | a print compatible format string. |
... | a print compatible list of arguments. |
void point | ( | int | x, |
int | y, | ||
int | color | ||
) |
Plot a point on the oLED screen.
x | Number of pixels from left side of screen. The value increases from 0 (left) to 127 (right). |
y | the number of pixels from the top of the screen. The value increases from 0 (top)to 63 (bottom). Color is 1 for white, 0 for black. |
color | The pixel color 1 for white, 0 for black. |
int receive | ( | char * | s | ) |
Receive a character string from another badge.
String length can be 128 or less.
*s | Address of the character array to store the string that was received. |
void retrieve | ( | char * | contact, |
int | recIdx | ||
) |
Copy string with a certain index number from EEPROM to a character array.
String length can be 128 or less.
*contact | Address of the array where the string should be copied. |
recIdx | Index number of the string. |
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. rgb(R, GREEN) makes the right one glow green. Color options include BLUE, GREEN, CYAN, YELLOW, RED, MAGENTA, WHITE. You can also use OFF to make a light that is glowing turn off. The numeric values of these are listed in Macros -> RGB LEDs.
side | Which side of the oLED screen (L or R) the RGB LED is on. |
color | RBG LED color setting. Options include BLUE, GREEN, CYAN, YELLOW, RED, MAGENTA, WHITE, and OFF. |
void rgbs | ( | int | colorL, |
int | colorR | ||
) |
Set both RGB LED colors with one function call. See rgb function for color options.
colorL | The color of the left RGB LED. |
colorR | The color of the right RGB LED. |
void screen_auto | ( | int | state | ) |
Cause function calls like oledprint, point, and others to appear immediately after the function is called with screen_auto(1). To make multiple changes before manually updating with a call to screen_update, use screen_auto(0). See 04 Screen Auto ON OFF.side for example.
state | 1 enables auto-update, 0 disables it. |
int screen_getAuto | ( | ) |
Check if function calls like oledprint, point, and others are set to appear (1) immediately after the function is called or (0) if multiple changes are made before manually updating with a call to screen_update.
void screen_image | ( | char * | imgaddr | ) |
Display an image using an array holding an image generated by software that is compatible with the screen's scanning. See 12 Image to Display.side for an example.
Although scanning starts at the top-left, each pixel in the byte advances downward. After displaying the 8 vertical pixels, it steps to the right a pixel for the next byte. The next byte starts one pixel to the right.
*imgaddr | Address of the byte array with the 128x64 pixel image to be displayed.. |
int screen_scrollLeft | ( | int | scrollStart, |
int | scrollStop | ||
) |
Cause the screen to scroll to the left with screen_scrollLeft(0, 15).
int screen_scrollLeftDiag | ( | int | scrollStart, |
int | scrollStop | ||
) |
Cause the screen to scroll diagonally to the left with screen_scrollLeftDiag(0, 15).
int screen_scrollRight | ( | int | scrollStart, |
int | scrollStop | ||
) |
Cause the screen to scroll to the right with screen_scrollRight(0, 15).
int screen_scrollRightDiag | ( | int | scrollStart, |
int | scrollStop | ||
) |
Cause the screen to scroll diagonally to the right with screen_scrollRightDiag(0, 15).
int screen_scrollStop | ( | void | ) |
Stop screen scrolling action.
int screen_update | ( | void | ) |
Manually update the screen image after. Typically used after multiple oLED function calls after screen_auto(0). See 04 Screen Auto ON OFF.side for example.
int send | ( | char * | s | ) |
Send a character string to another badge. Example: char s[] = "Hello other badge"; send(s);.
*s | Address of a string to send. |
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.side for example.
*img | array's address (its name without the square brackets). |
bw | Can be SCR_WHITE for 1s drawing white pixels, SCR_BLACK for 1s drawing black pixels, or SCR_XOR for inverting. |
xtl | The shape's x top-left coordinate. |
ytl | The shape's y top-left coordinate. |
xpics | The shape's width in pixels. |
ypics | The shape's height in pixels. |
int store | ( | char * | contact | ) |
Store a character string of up to 128 characters to EEPROM. Example: char s[] = "abcd"; store(s);.
String length can be 128 or less.
contact | Address of the string. |
int stored | ( | char * | s | ) |
Check if a string has already been stored in EEPROM. Example: if(!stored("abcd")) store("abcd");.
*s The address of the string that should be checked against strings stored in EEPROM. String length can be 128 or less.
void string | ( | char * | str | ) |
Display a character string on the oLED display.
String length can be 128 or less. Word wrap is automatic if line width is exceeded.
*str | Address of string to be displayed. |
void text_size | ( | int | size | ) |
Set the text size to either 32x16 pixel (LARGE) or 7x5 (SMALL) characters. Examples: text_size(LARGE);...text_size(SMALL)...text_size(LARGE).
size | Size of characters, either LARGE (32x16 pixels) or SMALL (7x5 pixels). |
void triangle | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | c | ||
) |
Plot a triangle on the oLED screen.
x0 | The x coordinate of one corner of the triangle. Measured as a number of pixels from left side of screen. The value increases from 0 (left) to 127 (right). |
y0 | The y coordinate of one corner of the triangle. Measured as a number of pixels from the top of the screen. The value increases from 0 (top) to 63 (bottom). |
x1 | The x coordinate of the second corner. |
y1 | The y coordinate of the second corner. |
x2 | The x coordinate of the third corner. |
y2 | The y coordinate of the third corner. |
c | The pixel color 1 for white, 0 for black. |
void triangleFilled | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | c | ||
) |
Plot a filled triangle on the oLED screen.
x0 | The x coordinate of one corner of the triangle. Measured as a number of pixels from left side of screen. The value increases from 0 (left) to 127 (right). |
y0 | The y coordinate of one corner of the triangle. Measured as a number of pixels from the top of the screen. The value increases from 0 (top) to 63 (bottom). |
x1 | The x coordinate of the second corner. |
y1 | The y coordinate of the second corner. |
x2 | The x coordinate of the third corner. |
y2 | The y coordinate of the third corner. |
c | The pixel color 1 for white, 0 for black. |