Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NeoStrip SerialDriver mbed-rtos mbed
main.cpp
- Committer:
- rossng
- Date:
- 2016-01-31
- Revision:
- 3:d331c534064f
- Parent:
- 2:868c8a43e4b7
- Child:
- 4:cea8cd2c44e4
File content as of revision 3:d331c534064f:
#include "mbed.h"
#include "SerialDriver.h"
#include "NeoStrip.h"
#include "gt.h"
#define N 64
SerialDriver rpi(p9, p10);
SerialDriver pc(USBTX, USBRX);
DigitalOut myled(LED1);
NeoStrip strip(p18, N);
int flash();
void set_pattern(NeoStrip strip);
int main() {
pc.printf("MBED: startup\n");
// setup serial port
rpi.baud(115200);
char* line_buffer = (char*) malloc(100*sizeof(char));
char c = rpi.getc();
int pos = 0;
while (c != '\n' && c != '\r') {
line_buffer[pos] = c;
c = rpi.getc();
pos++;
}
line_buffer[pos] = '\0';
rpi.printf("ack\n");
int result = strcmp(line_buffer, "hello");
if (result == 0) {
set_pattern(strip);
} else {
pc.printf("Did not match.\n");
pc.printf(line_buffer);
}
}
int flash() {
while(1) {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}
void set_pattern(NeoStrip strip) {
strip.setBrightness(0.2);
strip.setPixels(0, N, gt_img);
strip.write();
}