PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Classes | Functions
badgewxtools.h File Reference

This library provides convenient functions for a variety of Parallax eBadge operations.
More...

#include "simpletools.h"
#include <stdint.h>
+ Include dependency graph for badgewxtools.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  jm_ir_hdserial
 
struct  screen
 

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.
 

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...
 
Touch Buttons
char button (char b)
 Gets the state of a touch button/ nav slider (1) pressed, (0) not pressed. Numbering {7, 6, 5, 4, 3, 2, 1} maps the pads/positions by [L touch][L NAV left][L NAV ctr][L NAV right][R NAV left][R NAV ctr][R NAV right][R touch].
Example: int state = button(3); If state stores 1, it means the right nav slider is pressed down. If it instead stores 0, the slider is not pressed/slid. More...
 
unsigned char buttons (void)
 Gets the states of all eight touch buttons and nav sliders, and returns them in a value with 1s and 0s that correspond to each pad/position. Example: int states = buttons(); If states stores 0b10000010, it means: {left touchpad (B) pressed, left nav slider not in any position, right nav slider held right, right touchpad (A) not pressed}. More...
 
void touch_sensitivity_set (char sens)
 Used to set the RC time threshold used to detect a button press on the A and B touchpads on the back of the BadgeWX's PCB. Range is from 0 (low sensitivity) to 15 (high sensitivity). Default is 7.
 
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...
 
charee_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...
 
void led_pwm_start (void)
 Start the PWM driver for the discrete LEDs. Uses a cog.
 
void led_pwm_stop (void)
 Stop the PWM driver for the discrete LEDs. Frees the cog used by the driver.

 
void led_pwm_set (char side, char level)
 Set the brightness of the two discrete LEDs.
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...
 

Private (used by badgetools library)

#define RGB_PIN   (10)
 
#define LED_PIN   (9)
 
#define NAV_L   (13)
 
#define NAV_C   (12)
 
#define NAV_R   (11)
 
#define NAV_COM_L   (14)
 
#define NAV_COM_R   (15)
 
#define NAV_TOUCH_L   (4)
 
#define NAV_TOUCH_R   (2)
 
#define IR_BAUD   (2400)
 
#define IR_FREQ   (36000)
 
#define IR_OUT   (3)
 
#define IR_IN   (23)
 
#define OLED_DAT   (21)
 
#define OLED_CLK   (20)
 
#define OLED_DC   (22)
 
#define OLED_RST   (19)
 
#define OLED_CS   (18)
 
#define TV_DAC2   (26)
 
#define TV_DAC1   (25)
 
#define TV_DAC0   (24)
 
#define AUD_RT   (1)
 
#define AUD_LF   (0)
 
#define STX   2
 
#define ETX   3
 
#define LCD_BUFFER_SIZE_BOTH_TYPES   (1024)
 
#define SSD1306_SWITCHCAPVCC   (2)
 
#define TYPE_128X32   (32)
 
#define TYPE_128X64   (64)
 
#define EE_BADGE_DATA_START   32768
 
#define EE_BADGE_DATA_END   65536 - 4
 
#define XOUT   0
 
#define YOUT   1
 
#define ZOUT   2
 
#define TILT   3
 
#define SRST   4
 
#define SPCNT   5
 
#define INTSU   6
 
#define MODE   7
 
#define SR   8
 
#define PDET   9
 
#define PD   10
 
#define MMA7660_I2C   0b1001100
 
#define ALERT_BIT   0b01000000
 
#define ALERT_XYZT   0x40404040
 
#define BUF_SIZE   (128)
 
#define BUF_MASK   ((BUF_SIZE - 1))
 
#define SSD1306_LCDWIDTH   (128)
 
#define SSD1306_LCDHEIGHT32   (32)
 
#define SSD1306_LCDHEIGHT64   (64)
 
#define SSD1306_LCDCHARMAX   (8)
 
#define SSD1306_SETCONTRAST   (129)
 
#define SSD1306_DISPLAYALLON_RESUME   (164)
 
#define SSD1306_DISPLAYALLON   (165)
 
#define SSD1306_NORMALDISPLAY   (166)
 
#define SSD1306_INVERTDISPLAY   (167)
 
#define SSD1306_DISPLAYOFF   (174)
 
#define SSD1306_DISPLAYON   (175)
 
#define SSD1306_SETDISPLAYOFFSET   (211)
 
#define SSD1306_SETCOMPINS   (218)
 
#define SSD1306_SETVCOMDETECT   (219)
 
#define SSD1306_SETDISPLAYCLOCKDIV   (213)
 
#define SSD1306_SETPRECHARGE   (217)
 
#define SSD1306_SETMULTIPLEX   (168)
 
#define SSD1306_SETLOWCOLUMN   (0)
 
#define SSD1306_SETHIGHCOLUMN   (16)
 
#define SSD1306_SETSTARTLINE   (64)
 
#define SSD1306_MEMORYMODE   (32)
 
#define SSD1306_COMSCANINC   (192)
 
#define SSD1306_COMSCANDEC   (200)
 
#define SSD1306_SEGREMAP   (160)
 
#define SSD1306_CHARGEPUMP   (141)
 
#define SSD1306_EXTERNALVCC   (1)
 
#define SSD1306_ACTIVATE_SCROLL   (47)
 
#define SSD1306_DEACTIVATE_SCROLL   (46)
 
#define SSD1306_SET_VERT_SCROLL_AREA   (163)
 
#define SSD1306_RIGHT_HORIZ_SCROLL   (38)
 
#define SSD1306_LEFT_HORIZ_SCROLL   (39)
 
#define SSD1306_VERTRIGHTHORIZSCROLL   (41)
 
#define SSD1306_VERTLEFTHORIZSCROLL   (42)
 
#define INLINE__   static
 
#define PostEffect__(X, Y)   (tmp__ = (X), (X) = (Y), tmp__)
 
#define Yield__()
 
#define waitcnt(n)   _waitcnt(n)
 
#define coginit(id, code, par)   _coginit((unsigned)(par)>>2, (unsigned)(code)>>2, id)
 
#define cognew(code, par)   coginit(0x8, (code), (par))
 
#define cogstop(i)   _cogstop(i)
 
typedef struct jm_ir_hdserial jm_ir_hdserial
 
typedef volatile struct screen screen
 
uint8_t oleddat []
 
static int32_t tmp__
 
int32_t ircom_start (int32_t rxd, int32_t txd, int32_t baud, int32_t freq)
 
void ircom_stop (void)
 
int32_t ircom_rx (void)
 
int32_t ircom_rxcheck (void)
 
int32_t ircom_rxtime (int32_t mslim)
 
int32_t ircom_rxflush (void)
 
int32_t ircom_tx (int32_t c)
 
int32_t ircom_str (char *p_zstr)
 
int32_t ircom_dec (int32_t value)
 
int32_t ircom_rjdec (int32_t val, int32_t width, int32_t pchar)
 
int32_t ircom_hex (int32_t value, int32_t digits)
 
int32_t ircom_tx_bin (int32_t value, int32_t digits)
 
int32_t ircom_txflush (void)
 
void led_pwm (void)
 
void init_MMA7660FC (void)
 
void ee_init (void)
 
void screen_string8x2 (char *str, int32_t len, int32_t row, int32_t col)
 
void screen_string16x4 (char *str, int len, int row, int col)
 
void screen_char32x16 (int ch, int row, int col)
 
void screen_char7x5 (int ch, int row, int col)
 
int screen_HIGH (int Pin)
 
int screen_LOW (int Pin)
 
int32_t screen_swap (int32_t a, int32_t b)
 
int screen_AutoUpdateOn (void)
 
int screen_AutoUpdateOff (void)
 
void ee_displayIndex (int start, int end, int increment)
 
void stringView (char *s, int ssize)
 
int sscan_ct (const char *str, const char *fmt,...)
 
int _doscanf_ct (const char *str, const char *fmt, va_list args)
 
void ir_start (void)
 
void ir_stop (void)
 
void ee_badgeCheck (void)
 
int light_start (void)
 
int touch_start (int count, unsigned char *p_pins, int dms)
 
int screen_GetDisplayHeight (void)
 
int screen_GetDisplayWidth (void)
 
int screen_GetDisplayType (void)
 
int screen_ssd1306_Command (int thecmd)
 
int screen_ssd1306_Data (int thedata)
 
int screen_getSplash (void)
 
int screen_SHIFTOUT (int Dpin, int Cpin, int CSpin, int Bits, int Value)
 
int screen_WRITEBUFF (int Dpin, int Cpin, int CSpin, int Bits, int Addr)
 
int screen_init (int ChipSelect, int DataCommand, int TheData, int TheClock, int Reset, int VCC_state, int Type)
 
int screen_getBuffer (void)
 
int screen_start (void)
 
int screen_stop (void)
 
int get_bit (int bitNum, int val)
 
void set_bit (int bitNum, int *val)
 
void clear_bit (int bitNum, int *val)
 
INLINE__ int32_t Min__ (int32_t a, int32_t b)
 
INLINE__ int32_t Max__ (int32_t a, int32_t b)
 
INLINE__ int32_t Shr__ (uint32_t a, uint32_t b)
 
INLINE__ int32_t Rotl__ (uint32_t a, uint32_t b)
 
INLINE__ int32_t Rotr__ (uint32_t a, uint32_t b)
 
INLINE__ int32_t Lookup__ (int32_t x, int32_t b, int32_t a[], int32_t n)
 

Detailed Description

This library provides convenient functions for a variety of Parallax eBadge operations.

Author
Parallax Inc.
Version
0.5

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.nosp@m.r@pa.nosp@m.ralla.nosp@m.x.co.nosp@m.m.

To-do:

Definition in file badgewxtools.h.


Class Documentation

◆ jm_ir_hdserial

struct jm_ir_hdserial

Definition at line 1526 of file badgetools.h.

+ Collaboration diagram for jm_ir_hdserial:
Class Members
volatile int32_t bitticks
volatile int32_t cog
volatile int32_t frsetup
volatile uint8_t rxbuf[BUF_SIZE]
volatile int32_t rxhead
volatile int32_t rxhub
volatile int32_t rxpin
volatile int32_t rxtail
volatile uint8_t txbuf[BUF_SIZE]
volatile int32_t txhead
volatile int32_t txhub
volatile int32_t txpin
volatile int32_t txtail

◆ screen

struct screen

Definition at line 1709 of file badgetools.h.

+ Collaboration diagram for screen:
Class Members
volatile int AutoUpdate
volatile uint8_t buffer[LCD_BUFFER_SIZE_BOTH_TYPES]
volatile int charSize
volatile int CLK
volatile int cog
volatile int command
volatile int crsrX
volatile int crsrY
volatile int CS
volatile int DATA
volatile int DC
volatile int displayHeight
volatile int displayType
volatile int displayWidth
volatile int RST
volatile int vccstate

Function Documentation

◆ accel()

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.

Parameters
axisThe AX, AY, or AZ sensing axis.

Definition at line 42 of file accelerometer.c.

◆ accel_shaken()

int accel_shaken ( void  )

Check if accelerometer was shaken recently, within the last half second.

Returns
1 if shaken, 0 if not.

Definition at line 15 of file accel_shaken.c.

◆ accels()

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).

Parameters
*xAddress of the variable for storing the x-axis measurement.
*yAddress of the variable for storing the y-axis measurement.
*zAddress of the variable for storing the z-axis measurement.

Definition at line 56 of file accelerometer.c.

+ Here is the call graph for this function:

◆ badge_setup()

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().

Returns
0.

Definition at line 29 of file badgealpha.c.

◆ box()

void box ( int  x0,
int  y0,
int  x1,
int  y1,
int  c 
)

Plot a box on the oLED screen.

Parameters
x0The 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).
y0The 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).
x1The x coordinate of a corner diagonal from the first corner.
y1The y coordinate of the corner diagonal from the first corner.
cThe pixel color 1 for white, 0 for black.

◆ boxFilled()

void boxFilled ( int  x0,
int  y0,
int  x1,
int  y1,
int  c 
)

Plot a filled box on the oLED screen.

Parameters
x0The 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).
y0The 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).
x1The x coordinate of a corner diagonal from the first corner.
y1The y coordinate of the corner diagonal from the first corner.
cThe pixel color 1 for white, 0 for black.

◆ button()

char button ( char  b)

Gets the state of a touch button/ nav slider (1) pressed, (0) not pressed. Numbering {7, 6, 5, 4, 3, 2, 1} maps the pads/positions by [L touch][L NAV left][L NAV ctr][L NAV right][R NAV left][R NAV ctr][R NAV right][R touch].
Example: int state = button(3); If state stores 1, it means the right nav slider is pressed down. If it instead stores 0, the slider is not pressed/slid.

Returns
Binary 1 if pressed; 0 if not pressed.

Definition at line 57 of file buttons.c.

+ Here is the call graph for this function:

◆ buttons()

unsigned char buttons ( void  )

Gets the states of all eight touch buttons and nav sliders, and returns them in a value with 1s and 0s that correspond to each pad/position. Example: int states = buttons(); If states stores 0b10000010, it means: {left touchpad (B) pressed, left nav slider not in any position, right nav slider held right, right touchpad (A) not pressed}.

Returns
An 8-bit value with binary 1/0 digits indicating the on/off state of the 7 touch buttons. The rightmost binary digit indicates the state of the upper-right button by the P27 label. The second from the right indicates the state of the button by the P26 label, and so on, up through the 5th from the right,

Gets the states of all eight touch buttons and nav sliders, and returns them in a value with 1s and 0s that correspond to each pad/position. Example: int states = buttons(); If states stores 0b10000010, it means: {left touchpad (B) pressed, left nav slider not in any position, right nav slider held right, right touchpad (A) not pressed}.

Returns
A 7-bit value with binary 1/0 digits indicating the on/off state of the 7 touch buttons. The rightmost binary digit indicates the state of the upper-right button by the P27 label. The second from the right indicates the state of the button by the P26 label, and so on, up through the 5th from the right,

Definition at line 90 of file jm_touchpads.c.

+ Here is the call graph for this function:

◆ circle()

void circle ( int  x0,
int  y0,
int  r,
int  c 
)

Plot a circle on the oLED screen.

Parameters
x0The 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).
y0The 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).
rThe radius of the circle.
cThe pixel color 1 for white, 0 for black.

◆ circleFilled()

void circleFilled ( int  x0,
int  y0,
int  r,
int  c 
)

Plot a filled circle on the oLED screen.

Parameters
x0The 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).
y0The 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).
rThe radius of the circle.
cThe pixel color 1 for white, 0 for black.

◆ clear()

int clear ( void  )

Clear the display.

Returns cursor to top-left 0, 0.

Definition at line 7 of file oled_clear.c.

+ Here is the call graph for this function:

◆ contacts_count()

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.

Returns
Number of contacts.

Definition at line 11 of file peb_contacts_count.c.

◆ contacts_setStartAddr()

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.

Parameters
addressEEPROM starting address for contact storage.

Definition at line 12 of file peb_contacts_setStartAddr.c.

◆ cursor()

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.

Parameters
colthe column (character position) from left.
rowthe row (line number) from top.

Definition at line 7 of file oled_cursor.c.

◆ dev_ee_show()

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.

Parameters
byteCountNumber of bytes to display.
addressStarting EEPROM address.

Definition at line 12 of file peb_dev_ee_show.c.

+ Here is the call graph for this function:

◆ ee_readByte()

char ee_readByte ( int  addr)

Get a byte value from a certain address in the Propeller Chip's dedicated EEPROM.

Parameters
addrThe EEPROM address that with the byte value that should be fetched.
Returns
value The byte value stored by the EEPROM at the address specified by the addr parameter.

Definition at line 13 of file peb_ee_readByte.c.

+ Here is the call graph for this function:

◆ ee_readFloat32()

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.

Parameters
addrThe EEPROM address with the 32-bit floating point float value that should be fetched.
Returns
value The float value stored by the EEPROM at the specified address.

Definition at line 13 of file peb_ee_readFloat32.c.

+ Here is the call graph for this function:

◆ ee_readInt()

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.

Parameters
addrThe EEPROM address with the int value that should be fetched.
Returns
value The int value stored by the EEPROM at the specified address.

Definition at line 13 of file peb_ee_readInt.c.

+ Here is the call graph for this function:

◆ ee_readShort()

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.

Parameters
addrThe EEPROM address with the int value that should be fetched.
Returns
value The int value stored by the EEPROM at the specified address.

Definition at line 13 of file peb_ee_readShort.c.

+ Here is the call graph for this function:

◆ ee_readStr()

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.

Parameters
sAddress of a char array to receive the string of bytes fetched from EEPROM.
nThe number of bytes to copy from EEPROM to the array.
addrThe EEPROM address of the first byte in the string.
Returns
The address of the array that stores the characters that were fetched.

Definition at line 13 of file peb_ee_readStr.c.

+ Here is the call graph for this function:

◆ ee_writeByte()

void ee_writeByte ( unsigned char  value,
int  addr 
)

Store a byte value at a certain address in the Propeller Chip's dedicated EEPROM.

Parameters
valueThe byte value to store in EEPROM.
addrThe EEPROM address where the value is to be stored.

Definition at line 13 of file peb_ee_writeByte.c.

+ Here is the call graph for this function:

◆ ee_writeFloat32()

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.

Parameters
fpValThe 32-bit floating point float value to store in EEPROM.
addrThe EEPROM address where the value is to be stored.

Definition at line 13 of file peb_ee_writeFloat32.c.

+ Here is the call graph for this function:

◆ ee_writeInt()

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.

Parameters
valueThe int value to store in EEPROM.
addrThe EEPROM address where the value is to be stored.

Definition at line 13 of file peb_ee_writeInt.c.

+ Here is the call graph for this function:

◆ ee_writeShort()

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.

Parameters
valueThe int value to store in EEPROM.
addrThe EEPROM address where the value is to be stored.

Definition at line 13 of file peb_ee_writeShort.c.

+ Here is the call graph for this function:

◆ ee_writeStr()

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.

Parameters
sAddress of a char array containing the string of bytes.
nThe number of bytes to copy from the array.
addrThe EEPROM address of the first byte in the string.

Definition at line 13 of file peb_ee_writeStr.c.

+ Here is the call graph for this function:

◆ eeprint()

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.

Parameters
*fmta print compatible format string.
...a print compatible list of arguments.
Returns
Record index number in EEPROM.

Definition at line 12 of file peb_eeprint.c.

+ Here is the call graph for this function:

◆ eeprinted()

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.

Parameters
*fmta print compatible format string.
...a print compatible list of arguments.
Returns
0 if not in EEPROM, or the record number if it is.

Definition at line 12 of file peb_eeprinted.c.

◆ eescan()

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.

Parameters
recIdxAn integer record index value.
*fmta print compatible format string.
...a print compatible list of arguments.
Returns
The number of blocks successfully scanned.

Definition at line 12 of file peb_eescan.c.

+ Here is the call graph for this function:

◆ ir_receive()

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.

Parameters
*sAddress of the character array to store the string that was received.
ssizeMaximmum size of the string.
Returns
The length of the sting.

Definition at line 31 of file peb_ir_receive.c.

◆ ir_send()

void ir_send ( char s,
int  ssize 
)

Transmits a string with a specified number of characters over IR.

ssize can be 128 or less.

Parameters
*sAddress of a string to send.
ssizeMaximmum size of the string.

Definition at line 11 of file peb_ir_send.c.

◆ irprint()

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.

Parameters
*fmta print compatible format string.
...a print compatible list of arguments.
Returns
Record index number in EEPROM.

Definition at line 4 of file peb_irprint.c.

+ Here is the call graph for this function:

◆ irscan()

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.

Parameters
*fmta print compatible format string.
...a print compatible list of arguments.
Returns
The number of blocks successfully scanned.

Definition at line 4 of file peb_irscan.c.

+ Here is the call graph for this function:

◆ led_pwm_set()

void led_pwm_set ( char  side,
char  level 
)

Set the brightness of the two discrete LEDs.

Parameters
sideWhich discrete LED to change (0-left or 1-right).
led_rightThe brightness of the specified discrete LED, ranges from 0 (off) to 15 (full brightness).

Definition at line 34 of file led_pwm.c.

◆ line()

void line ( int  x0,
int  y0,
int  x1,
int  y1,
int  c 
)

Plot a line on the oLED screen.

Parameters
x0The 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).
y0The 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).
x1The x coordinate of the second point in the line.
y1The y coordinate of the second point in the line.
cThe pixel color 1 for white, 0 for black.

◆ oledprint()

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.

Parameters
*fmta print compatible format string.
...a print compatible list of arguments.
Returns
Record index number in EEPROM.

Definition at line 4 of file peb_text.c.

+ Here is the call graph for this function:

◆ point()

void point ( int  x,
int  y,
int  color 
)

Plot a point on the oLED screen.

Parameters
xNumber of pixels from left side of screen. The value increases from 0 (left) to 127 (right).
ythe 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.
colorThe pixel color 1 for white, 0 for black.

◆ receive()

int receive ( char s)

Receive a character string from another badge.

String length can be 128 or less.

Parameters
*sAddress of the character array to store the string that was received.
Returns
The length of the string.

Definition at line 6 of file peb_ir_receive.c.

+ Here is the call graph for this function:

◆ retrieve()

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.

Parameters
*contactAddress of the array where the string should be copied.
recIdxIndex number of the string.

Definition at line 12 of file peb_retrieve.c.

◆ screen_auto()

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.

Parameters
state1 enables auto-update, 0 disables it.

Definition at line 7 of file oled_auto.c.

◆ screen_getAuto()

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.

Returns
1 if auto-update is enabled, or 0 if it is not.

Definition at line 7 of file oled_getAuto.c.

◆ screen_image()

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.

Parameters
*imgaddrAddress of the byte array with the 128x64 pixel image to be displayed..
Returns
.

Definition at line 6 of file peb_screen_image.c.

◆ screen_scrollLeft()

int screen_scrollLeft ( int  scrollStart,
int  scrollStop 
)

Cause the screen to scroll to the left with screen_scrollLeft(0, 15).

Returns
0

◆ screen_scrollLeftDiag()

int screen_scrollLeftDiag ( int  scrollStart,
int  scrollStop 
)

Cause the screen to scroll diagonally to the left with screen_scrollLeftDiag(0, 15).

Returns
0

◆ screen_scrollRight()

int screen_scrollRight ( int  scrollStart,
int  scrollStop 
)

Cause the screen to scroll to the right with screen_scrollRight(0, 15).

Returns
0

◆ screen_scrollRightDiag()

int screen_scrollRightDiag ( int  scrollStart,
int  scrollStop 
)

Cause the screen to scroll diagonally to the right with screen_scrollRightDiag(0, 15).

Returns
0

◆ screen_scrollStop()

int screen_scrollStop ( void  )

Stop screen scrolling action.

Returns
0

Definition at line 7 of file oled_scrollStop.c.

◆ screen_update()

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.

Returns
0

Definition at line 426 of file oled_asmfast.c.

◆ send()

int send ( char s)

Send a character string to another badge. Example: char s[] = "Hello other badge"; send(s);.

Parameters
*sAddress of a string to send.
Returns
Length of the string that was sent.

Definition at line 4 of file peb_ir_send.c.

+ Here is the call graph for this function:

◆ 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.side for example.

Parameters
*imgarray's address (its name without the square brackets).
bwCan be SCR_WHITE for 1s drawing white pixels, SCR_BLACK for 1s drawing black pixels, or SCR_XOR for inverting.
xtlThe shape's x top-left coordinate.
ytlThe shape's y top-left coordinate.
xpicsThe shape's width in pixels.
ypicsThe shape's height in pixels.

Definition at line 6 of file peb_shape.c.

◆ store()

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.

Parameters
contactAddress of the string.
Returns
Index of the record in EEPROM. The first record gets an index of 0, the second an index of 1, and so-on.

Definition at line 12 of file peb_store.c.

◆ stored()

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.

Returns
1 if a matching record was found, or 0 if not.

Definition at line 12 of file peb_already_stored.c.

◆ string()

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.

Parameters
*strAddress of string to be displayed.

Definition at line 7 of file oled_string.c.

◆ text_size()

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).

Parameters
sizeSize of characters, either LARGE (32x16 pixels) or SMALL (7x5 pixels).

Definition at line 7 of file oled_text_size.c.

◆ triangle()

void triangle ( int  x0,
int  y0,
int  x1,
int  y1,
int  x2,
int  y2,
int  c 
)

Plot a triangle on the oLED screen.

Parameters
x0The 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).
y0The 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).
x1The x coordinate of the second corner.
y1The y coordinate of the second corner.
x2The x coordinate of the third corner.
y2The y coordinate of the third corner.
cThe pixel color 1 for white, 0 for black.

◆ triangleFilled()

void triangleFilled ( int  x0,
int  y0,
int  x1,
int  y1,
int  x2,
int  y2,
int  c 
)

Plot a filled triangle on the oLED screen.

Parameters
x0The 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).
y0The 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).
x1The x coordinate of the second corner.
y1The y coordinate of the second corner.
x2The x coordinate of the third corner.
y2The y coordinate of the third corner.
cThe pixel color 1 for white, 0 for black.