|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
8 #define Empty_Main_Function
54 #ifdef Empty_Main_Function
63 #endif // Empty_Main_Function
66 #ifdef ActivityBot_Buttons_Host
94 int event, id, handle;
97 int speedLeft = 0, speedRight = 0;
104 print(
"navId = %d\n", navId);
111 print(
"event: %c, id: %d, handle: %d\r",
118 print(
"Incoming POST request\r");
121 print(
"go=%c\n", buttonCmd);
130 if(speedLeft > speedRight) speedRight = speedLeft;
131 else if(speedRight > speedLeft) speedLeft = speedRight;
147 if(speedLeft < speedRight) speedRight = speedLeft;
148 else if(speedRight < speedLeft) speedLeft = speedRight;
160 if(speedLeft >= 128) speedLeft = 128;
161 if(speedLeft <= -128) speedLeft = -128;
162 if(speedRight >= 128) speedRight = 128;
163 if(speedRight <= -128) speedRight = -128;
166 print(
"speedLeft = %d, speedRight = %d\r", speedLeft, speedRight);
173 #endif // ActivityBot_Buttons_Host
176 #ifdef ActivityBot_Buttons_IR_Speed_Host
208 int event, id, handle;
209 int navId, spdId, irId;
210 char buttonCmd, buttonCmdPrev;
211 int speedLeft = 0, speedRight = 0, speedVal = 50;
219 print(
"navId: %d\r", navId);
222 print(
"spdId: %d\r", spdId);
225 print(
"irId: %d\r", irId);
232 print(
"event: %c, id: %d, handle: %d\r",
237 print(
"Incoming POST request\r");
241 print(
"go=%c\r", buttonCmd);
242 buttonCmdPrev = buttonCmd;
247 print(
"v=%d\r", speedVal);
248 buttonCmd = buttonCmdPrev;
251 else if(event ==
'G')
253 print(
"Incoming GET request\r");
263 print(
"Reply: %01b%01b\r", irLeft, irRight);
273 speedLeft = speedVal;
274 speedRight = speedVal;
277 speedLeft = -speedVal;
278 speedRight = speedVal;
281 speedLeft = speedVal;
282 speedRight = -speedVal;
285 speedLeft = -speedVal;
286 speedRight = -speedVal;
293 print(
"speedLeft: %d, speedRight: %d\r", speedLeft, speedRight);
301 #endif // ActivityBot_Buttons-IR_Speed_Host
304 #ifdef IFTTT_Send_Email
333 int event, id, handle;
347 "POST /trigger/MicrocontrollerEvent/with/key/"\
348 "YourKeyYourKeyYourKeyYourKeyYourKeyYourKeyY"\
350 "Host: maker.ifttt.com\r\n"\
351 "Connection: keep-alive\r\n"\
352 "Accept: *" "/" "*\r\n\r\n";
354 int size = strlen(request);
363 print(
"str = %s\r", str);
366 #endif // IFTTT_Email
370 #ifdef Light_Controls_Canvas_Host
393 int event, id, handle;
402 print(
"getFromPageId = %d\n", lightId);
407 print(
"event = %c, id = %d, handle = %d\r",
419 print(
"Reqply to GET request:%d\n", lightVal);
426 #endif // Light_Controls_Canvas_Host
430 #ifdef Page_Controls_light_Host
453 int event, id, handle;
454 int ledId, pin, state;
460 print(
"ledId = %d\n", ledId);
468 print(
"event = %c, id = %d, handle = %d\r", event,
id, handle);
473 print(
"Incoming POST request\r");
475 print(
"pin=%d, state=%d\n", pin, state);
483 #endif // Page_Controls_light_Host
486 #ifdef Page_Controls_Servo_Host
510 int event, id, handle;
517 print(
"ledId = %d\n", servoId);
525 print(
"event = %c, id = %d, handle = %d\r", event,
id, handle);
531 print(
"Incoming POST request\r");
533 print(
"servoAngle: %d\n", angle);
541 #endif // Page_Controls_Servo_Host
544 #ifdef Page_Displays_Buttons_Host
567 int event, id, handle;
569 int buttonP3, buttonP4;
579 print(
"getFromPageId = %d\n", buttonId);
584 print(
"event = %c, id = %d, handle = %d\r", event,
id, handle);
592 print(
"Incoming GET request, sending %d%d\r", buttonP3, buttonP4);
599 #endif // Page_Displays_Buttons_Host
602 #ifdef Pot_Controls_Canvas_Host
627 int event, id, handle;
636 print(
"dialId = %d\n", dialId);
643 print(
"event: %c, id: %d, handle: %d\r",
650 dialAngle =
ad_in(3);
654 print(
"Incoming GET request, sending %d\r", dialAngle);
662 #endif // Pot_Controls_Canvas_Host
666 #ifdef Test_Join_Leave
684 print(
"test join\r");
687 int ip[] = {0, 0, 0, 0};
692 }
while(ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0);
693 print(
"\rip=%d.%d.%d.%d\r", ip[0], ip[1], ip[2], ip[3]);
697 print(
"mode=%d\r", mode);
702 print(
"mode=%d\r", mode);
705 print(
"test join\r");
712 }
while(ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0);
713 print(
"\rip=%d.%d.%d.%d\r", ip[0], ip[1], ip[2], ip[3]);
716 print(
"mode=%d\r", mode);
719 #endif // Test_Join_Leave
723 #ifdef Test_Serial_Commands
748 print(
"=======================================\r");
749 print(
"wifi_print/scan tests\r");
750 print(
"=======================================\r\r");
753 print(
"Test controlling Wi-Fi module I/O\r");
754 print(
"Set /CTS ouput-high\r");
757 print(
"status: %c\r", status);
759 print(
"Check /CTS\r");
762 print(
"status: %c, pinState: %d\r", status, pinState);
764 print(
"Set /CTS ouput-low\r");
768 print(
"status: %c\r", status);
770 print(
"Check /CTS\r");
773 print(
"status: %c, pinState: %d\r", status, pinState);
775 print(
"Check /CTS for pull-up when \rinput should return high\r");
778 print(
"status: %c, pinState: %d\r\r", status, pinState);
781 print(
"Check station IP address\r");
782 int ip[4] = {0, 0, 0, 0};
784 wifi_scan(
CMD, NULL,
"%c%d%d%d%d", &status, &ip[0], &ip[1], &ip[2], &ip[3]);
785 print(
"Station IP: %d.%d.%d.%d\r\r", ip[0], ip[1], ip[2], ip[3]);
792 print(
"Check firmware version\r");
795 print(
"Truncated reply: %4.2f\r", version);
797 print(
"charcount: %d\rfull reply: %s\r", charcount, temp);
800 print(
"=======================================\r");
801 print(
"wifi_command tests\r");
802 print(
"=======================================\r\r");
807 print(
"Test controlling Wi-Fi module I/O\r");
808 print(
"Set /CTS ouput-high\r");
810 print(
"reply: %s", reply);
812 print(
"Check /CTS\r");
814 print(
"reply: %s", reply);
816 print(
"Set /CTS ouput-low\r");
818 print(
"reply: %s", reply);
820 print(
"Check /CTS\r");
822 print(
"reply: %s", reply);
824 print(
"Check /CTS for pull-up when \rinput should return high\r");
826 print(
"reply: %s\r", reply);
831 print(
"Check firmware version\r");
833 print(
"reply: %s\r", reply);
836 print(
"Check module name\r");
839 print(
"Module name: %s\r\r", &s[1]);
843 print(
"Check network mode\r");
845 print(
"reply: %s\r", reply);
849 print(
"Check network mode\r");
851 print(
"reply: %s\r", reply);
854 print(
"Check station IP address\r");
856 print(
"reply: %s\r", reply);
939 #endif // Test_Join_Leave
942 #ifdef Text_from_www_page_with_TCP
969 int event, id, handle;
982 char request[] =
"GET /documents/a_document.txt "\
984 "Host: www-eng-x.llnl.gov\r\n\r\n\0";
986 int size = strlen(request);
995 print(
"str = %s\r", str);
998 #endif // Text_from_www_page_with_TCP
1001 #ifdef Temperature_From_OpenWeatherMap
1035 int event, id, handle;
1044 int tcpHandle =
wifi_connect(
"api.openweathermap.org", 80);
1046 print(
"tcpHandle = %d\r", tcpHandle);
1055 "GET /data/2.5/weather?zip=95677,us"\
1056 "&appid=YourKeyYourKeyYourKeyYourKeyYour"\
1058 "Host: api.openweathermap.org\r\n"\
1059 "Connection: keep-alive\r\n"\
1060 "Accept: *" "/" "*\r\n\r\n";
1062 int size = strlen(request);
1064 print(
"GET req size: %d\r", size);
1073 print(
"size = %d", size);
1077 for(
int n = 0; n <
sizeof(str); n++)
1079 if(str[n] <=
'z' && str[n] >=
' ')
1081 print(
"%c", str[n]);
1083 else if(str[n] == 0)
1085 print(
"[%d]", str[n]);
1088 else if(str[n] ==
'\n')
1090 print(
"\r", str[n]);
1094 print(
"[%d]", str[n]);
1097 char *loc = strstr(str,
"temp");
1098 print(
"\rloc = %d\r", loc);
1100 sscan(loc+5,
"%f", &temp);
1101 float degC = temp -273.15;
1102 print(
"temp = %6.2f deg C\r", degC);
1103 float degF = degC * 9.0 / 5.0 + 32.0;
1104 print(
"temp = %6.2f deg C\r", degF);
1107 #endif // Temperature_from_OpenWeatherMap
1110 #ifdef Text_Page_to_Micro_Host
1132 int event, id, handle;
1140 print(
"postFromPageId = %d\n", postFromPageId);
1145 print(
"event = %c, id = %d, handle = %d\r", event,
id, handle);
1148 if(
id == postFromPageId)
1150 print(
"Incoming POST request\r");
1153 print(
"text = %s n = %d\n", s, n);
1160 #endif // Text_Page_to_Micro_Host
1163 #ifdef Val_from_Micro_Host
1185 int event, id, handle;
1194 print(
"getFromPageId = %d\n", getFromPageId);
1200 print(
"event = %c, id = %d, handle = %d\r", event,
id, handle);
1203 if(
id == getFromPageId)
1205 print(
"Incoming GET request, sending %d\r", val);
1213 #endif // Val_from_Micro_Host
1216 #ifdef Ws_ActivityBot_Btns_Ir_Speed_Host
1248 int event, id, handle;
1249 int wsId, wsHandle = 0;
1250 int navChar, buttonCmd, buttonCmdPrev;
1251 int val, speedVal, speedLeft, speedRight;
1252 int irLeft, irRight;
1259 print(
"wsId = %d\n", wsId);
1271 print(
"wsHandle = %d\n\n", wsHandle);
1274 else if(event ==
'D')
1279 if(buttonCmd ==
'v')
1281 buttonCmd = buttonCmdPrev;
1286 buttonCmdPrev = buttonCmd;
1305 speedLeft = speedVal;
1306 speedRight = speedVal;
1309 speedLeft = -speedVal;
1310 speedRight = speedVal;
1313 speedLeft = speedVal;
1314 speedRight = -speedVal;
1317 speedLeft = -speedVal;
1318 speedRight = -speedVal;
1335 #endif // Ws_ActivityBot_Btns_Ir_Speed_Host
1342 #ifdef Ws_Disconnect_Test
1375 int event, id, handle;
1376 int wsId, wsHandle = 0;
1377 int navChar, buttonCmd, buttonCmdPrev;
1378 int val, speedVal, speedLeft, speedRight;
1379 int irLeft, irRight;
1386 print(
"wsId = %d\n", wsId);
1398 print(
"wsHandle = %d\n\n", wsHandle);
1401 else if(event ==
'D')
1406 if(buttonCmd ==
'v')
1408 buttonCmd = buttonCmdPrev;
1413 buttonCmdPrev = buttonCmd;
1432 speedLeft = speedVal;
1433 speedRight = speedVal;
1436 speedLeft = -speedVal;
1437 speedRight = speedVal;
1440 speedLeft = speedVal;
1441 speedRight = -speedVal;
1444 speedLeft = -speedVal;
1445 speedRight = -speedVal;
1447 print(
"discon = %d\r");
1463 #endif // Ws_ActivityBot_Btns_Ir_Speed_Host
#define HTTP
One of the argument option tokens that can be used with the LISTEN command token to set up an HTTP ev...
#define GET
A token returned by POLL to indicate that a GET request with a path that matched one on a listener ha...
int ad_in(int channel)
Get input value that corresponds to voltage measurement on one of the A/D converter's input channels....
int servo_angle(int pin, int degreeTenths)
Set Parallax Standard Servo to angle from 0 to 180 in tenths of a degree.
API for the Parallax WX Wi-Fi Module ESP8266-WROOM-02 (Part #32420). This library has a preliminary A...
void wifi_setBuffer(char *buffer, int size)
Sets the Wi-Fi buffer to an user declared external character array.
fdserial * wifi_start(int fromDO, int toDI, int baud, int comSelect)
Set up Wi-Fi module serial connections for data command and transparent data communication.
void drive_speed(int left, int right)
Set wheel speeds in encoder ticks per second. An encoder tick is 1/64th of a revolution,...
#define STA
Token used for both setting up and indicating station mode. In this mode, the Wi-Fi module is a stati...
int wifi_mode(int mode)
Set or check the Wi-Fi module's network mode.
#define CHECK
Command token used to check a Wi-Fi module setting or I/O pin state.
void wifi_poll(int *event, int *id, int *handle)
Check for activity like incoming HTTP GET/POST requests, HTTP/WebSocket/TCP connections/disconnection...
char * wifi_command(char *command)
Send a string command to the Wi-Fi module using its serial protocol, and get the Wi-Fi module's respo...
#define STA_AP
Token used for both setting up and indicating station plus access point mode. This mode should only b...
#define TCP
Constant that can be passed to the wifi_print/scan's type parameter to tell it to treat the formatted...
int wifi_replyStringCopy(char *targetStr)
Copy a reply from the libwifi response buffer to a character array.
int wifi_join(char *network, char *password)
Attempt to join a network via the ssid access point using passphrase.
Control up to 14 servos in another core. For up to 28, add the servoAux library to your project....
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
int wifi_scan(int protocol, int handle, const char *fmt,...)
The Wi-Fi module version of the simpletext library's scan function. It simplifies extracting data c...
#define GPIO_CTS
Token used in conjunction with the SET/CHECK command tokens to set/check the 1/0 output/input states ...
#define POST
A token returned by POLL to indicate that a POST request with a path that matched one set up on a lis...
int wifi_leave(int newMode)
Leave an AP network and transition into a mode that's not pure STA. The wi-fi module will forget the ...
Functions for setting voltages with D/A0, D/A1 outputs and measuring voltages with A/D0....
int wifi_connect(char *address, int port)
Attempt a TCP connection to address on port.
int wifi_listen(char protocol, char *path)
Activate a listener process to monitor HTTP or WebSocket protocol activity on port 80 with a specifie...
#define CMD
Begin marker token placed at the start of serial commands to the Wi-Fi module. Data that does not app...
This library takes care of encoder monitoring and servo signaling, and provides a simple set of funct...
int wifi_ip(int mode, int *ipAddr)
Check the IP address for the Parallax Wi-Fi module.
int wifi_print(int protocol, int handle, const char *fmt,...)
The Wi-Fi module version of the simpletext library's print function. It simplifies formatting data ...
int wifi_disconnect(int idOrHandle)
Terminate an established connection or listener via its handle or id (respectively),...
#define WS
One of the argument option tokens that can be used with the LISTEN command token to set up a WebSocke...
void ad_init(int csPin, int sclPin, int doPin, int diPin)
Initialize Activity Board A/D converter.
int int int int sscan(const char *buffer, const char *fmt,...) __attribute__((format(printf
Convert formatted buffer to the "..." args.