PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Badge
02 Lights
03 Control 6 Lights at a Time.c
1
/*
2
Control 6 Lights at a Time.c
3
Uses binary digits to control lights. This 0b101010 turns on lights
4
5, 3, and 1, and turns off 4, 2, and 0. Another way to think about it
5
is that it turns on the P17, P15, and P26 lights and turns off the P16,
6
P25 and P27 lights. Conversely, 0b010101turns on 4, 2, and 0 and turns
7
off 5, 3, and 1. That's P16, P25, P27 on, and P17, P15, and P26 off.
8
*/
9
10
#include "
simpletools.h
"
// Include simpletools library
11
#include "
badgetools.h
"
// Include badgetools library
12
13
void
main
()
// Main function
14
{
15
badge_setup
();
// Call badge setup
16
oledprint
(
" BITS"
);
// Display text
17
screen_auto
(
OFF
);
// Auto-update off
18
while
(1)
// Main loop
19
{
20
cursor
(0, 1);
// Column 0, line 1
21
oledprint
(
"0b101010"
);
// Prep binary value
22
screen_update
();
// Copy to display
23
24
leds
(0b101010);
// Same value sets LEDs
25
pause
(250);
// Wait 0.25 s
26
27
cursor
(0, 1);
// Reposition cursor
28
oledprint
(
"0b010101"
);
// Update binary value
29
screen_update
();
// ...and display
30
31
leds
(0b010101);
// Same value sets LEDs again
32
pause
(250);
// ...for another 0.25 s
33
}
34
}
35
36
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
cursor
void cursor(int col, int row)
Position the cursor to a certain column and row for printing text on the oLED display....
Definition:
oled_cursor.c:7
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
main
int main(void)
Definition:
GraphicsTest.c:20
oledprint
int oledprint(const char *fmt,...)
Use to display strings on the oLED display in a manner similar to displaying combinations of strings ...
Definition:
peb_text.c:4
badge_setup
int badge_setup(void)
Set up all available badge drivers. Call this function at the start of any given program to allow acc...
Definition:
badgealpha.c:29
leds
void leds(int bits)
Sets the on/off states of the 6 blue LEDs with a number that contains six binary 1/0 digits....
screen_auto
void screen_auto(int state)
Cause function calls like oledprint, point, and others to appear immediately after the function is ca...
Definition:
oled_auto.c:7
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.
screen_update
int screen_update(void)
Manually update the screen image after. Typically used after multiple oLED function calls after scree...
Definition:
oled_asmfast.c:426
OFF
#define OFF
OFF can be used in place of zero to enabled parameters in functions like drive_feedback and drive_tri...
Definition:
abdrive.h:204
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17