|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
23 void motor_controller();
24 void neopixel_controller();
25 void set_motor_controller(
int leftSpeed,
int rightSpeed);
29 void change_brightness(
int change_amount);
31 int ledColors[LED_COUNT];
32 int dim_array[LED_COUNT];
37 int eye_color = 0xFFFFFF;
43 volatile int current_leftspd = 0;
44 volatile int current_rightspd = 0;
45 volatile int motor_flag = 0;
47 int defaultStraightSpeed = 60;
48 int defaultTurnSpeed = 15;
72 int inputStringLength = 20;
73 char inputString[inputStringLength];
84 dprint(term,
"%d", (
int) c);
85 if (c == 13 || c == 10) {
86 dprint(term,
"received line:");
89 if (strcmp(inputString,
"l") == 0) {
91 set_motor_controller(-defaultTurnSpeed, defaultTurnSpeed);
93 if (strcmp(inputString,
"r") == 0) {
95 set_motor_controller(defaultTurnSpeed, -defaultTurnSpeed);
97 if (strcmp(inputString,
"f") == 0) {
99 set_motor_controller(defaultStraightSpeed, defaultStraightSpeed);
101 if (strcmp(inputString,
"b") == 0) {
103 set_motor_controller(-defaultStraightSpeed, -defaultStraightSpeed);
105 if (strcmp(inputString,
"l_up") == 0) {
106 dprint(term,
"left_stop");
109 if (strcmp(inputString,
"r_up") == 0) {
110 dprint(term,
"right_stop");
113 if (strcmp(inputString,
"f_up") == 0) {
114 dprint(term,
"forward_stop");
117 if (strcmp(inputString,
"b_up") == 0) {
118 dprint(term,
"back_stop");
121 if (strcmp(inputString,
"brightness_up") == 0) {
122 change_brightness(10);
123 dprint(term,
"brightness increased");
125 if (strcmp(inputString,
"brightness_down") == 0) {
126 change_brightness(-10);
127 dprint(term,
"brightness decreased");
129 if (strncmp(inputString,
"led", 3) == 0) {
133 dprint(term,
"%d\n", color);
134 if (pixel < LED_COUNT) {
135 ledColors[pixel] = color;
139 if (strncmp(inputString,
"leds", 4) == 0) {
142 dprint(term,
"%d\n", color);
143 for (
int i = 0; i < LED_COUNT; ++i) {
144 ledColors[i] = color;
151 else if (sPos < inputStringLength - 1) {
153 inputString[sPos] = c;
155 inputString[sPos] = 0;
156 dprint(term, inputString);
164 void set_motor_controller(
int leftSpeed,
int rightSpeed) {
165 current_leftspd = leftSpeed;
166 current_rightspd = rightSpeed;
170 void motor_controller() {
172 if (motor_flag == 1) {
185 void refresh_eyes() {
186 for (
int j = 0; j < LED_COUNT; ++j) {
187 int red = (ledColors[j] >> 16) & 0xFF;
188 red = red * brightness / 255;
190 int green = (ledColors[j] >> 8) & 0xFF;
191 green = green * brightness / 255;
193 int blue = (ledColors[j]) & 0xFF;
194 blue = blue * brightness / 255;
196 dim_array[j] = (red << 16) + (green << 8) + (blue);
198 ws2812_set(driver, LED_PIN, dim_array, LED_COUNT);
201 void change_brightness(
int change_amount) {
202 brightness =
constrainInt(brightness + change_amount, 2, 255);
209 while (doot < LED_COUNT) {
210 if (doot == 4 || doot == 13)
211 ledColors[doot] = 0x000000;
213 ledColors[doot] = eye_color;
221 while (doot < LED_COUNT) {
222 if ((doot >= 3 && doot <= 5) || (doot >= 12 && doot <= 14))
223 ledColors[doot] = eye_color;
225 ledColors[doot] = 0x000000;
233 while (doot < LED_COUNT) {
234 if (doot == 4 || doot == 13)
235 ledColors[doot] = 0x000000;
237 ledColors[doot] = eye_color;
int fdserial_rxReady(fdserial *term)
Check if a byte is ready in the receive buffer.
void drive_speed(int left, int right)
Set wheel speeds in encoder ticks per second. An encoder tick is 1/64th of a revolution,...
fdserial * fdserial_open(int rxpin, int txpin, int mode, int baudrate)
Open a full duplex serial connection.
int dprint(text_t *device, const char *format,...) __attribute__((format(printf
Print format "..." args to the device The output is limited to 256 bytes.
int servo360_couple(int pinA, int pinB)
This function is used by the abdrive360 library to reduce the drive on a servo whose position is furt...
int servo360_setControlSys(int pin, int constant, int value)
The servo360.h library is designed to use Proportional, Integral and Derivative (PID) control to main...
void simpleterm_close(void)
Closes the SimpleIDE Terminal connection in one cog so that it can be opened in another cog with simp...
int int int int int sscanAfterStr(char *buffer, char *str, char *fmt,...) __attribute__((format(printf
Store values represented by characters in a buffer in variable list using "..." args.
void ws2812_set(ws2812_t *driver, int pin, uint32_t *colors, int count)
Set color pattern on a chain of LEDs.
void drive_setAcceleration(int forGotoOrSpeed, int ticksPerSecSq)
Set the acceleration used by either drive_goto or drive_speed.
#define FOR_SPEED
This constant can be used in place of 0 to tell drive_setAcceleration and drive_setMaxVelocity to set...
int servo360_setCoupleScale(int pinA, int pinB, int scale)
Change the scale factor in a pair of servos that were coupled with the servo360_couple call....
Structure that contains data used by simple text device libraries.
This library provides a simple set of functions for making the ActivityBot 360 go certain distances a...
ws2812_t * ws2812b_open(void)
Open a driver for WS2812B chips.
int fdserial_rxChar(fdserial *term)
Get a byte from the receive buffer, or if it's emtpy, wait until a byte is received.
This library supports creating and managing one or more full duplex serial connections with periphera...