projectwerk

Dependencies:   NeoPixelI2cSlave mbed

Committer:
BramHeldenbergh
Date:
Sat Jan 09 13:10:35 2016 +0000
Revision:
0:75b8c5b36063
programma projectwerk

Who changed what in which revision?

UserRevisionLine numberNew contents of line
BramHeldenbergh 0:75b8c5b36063 1 #include "mbed.h"
BramHeldenbergh 0:75b8c5b36063 2 #include "neopixel_string.h"
BramHeldenbergh 0:75b8c5b36063 3 #include "i2c_device.h"
BramHeldenbergh 0:75b8c5b36063 4 #include "neopixel_string_factory.h"
BramHeldenbergh 0:75b8c5b36063 5 #include "neopixel_i2c_daemon.h"
BramHeldenbergh 0:75b8c5b36063 6 #include "strobe.h"
BramHeldenbergh 0:75b8c5b36063 7
BramHeldenbergh 0:75b8c5b36063 8 // This must be an SPI MOSI pin.
BramHeldenbergh 0:75b8c5b36063 9 #define DATA_PIN p5
BramHeldenbergh 0:75b8c5b36063 10 #define STRING_SIZE 8
BramHeldenbergh 0:75b8c5b36063 11
BramHeldenbergh 0:75b8c5b36063 12 #define DEBUG_MODE 1
BramHeldenbergh 0:75b8c5b36063 13 #include "log.h"
BramHeldenbergh 0:75b8c5b36063 14
BramHeldenbergh 0:75b8c5b36063 15 Serial pc(USBTX, USBRX); // tx, rx
BramHeldenbergh 0:75b8c5b36063 16
BramHeldenbergh 0:75b8c5b36063 17 int main() {
BramHeldenbergh 0:75b8c5b36063 18 pc.baud(115200);
BramHeldenbergh 0:75b8c5b36063 19 SimplyLog::Log::i("Neopixel driver loading\r\n");
BramHeldenbergh 0:75b8c5b36063 20
BramHeldenbergh 0:75b8c5b36063 21 I2cSettings settings;
BramHeldenbergh 0:75b8c5b36063 22 settings.frequency = 100000;
BramHeldenbergh 0:75b8c5b36063 23 settings.address = 0x80;
BramHeldenbergh 0:75b8c5b36063 24
BramHeldenbergh 0:75b8c5b36063 25 SimplyLog::Log::i("Slave is working @ %dHz\r\n", settings.frequency);
BramHeldenbergh 0:75b8c5b36063 26 SimplyLog::Log::i("Slave is working @ SLAVE_ADDRESS = 0x%x\r\n", settings.address);
BramHeldenbergh 0:75b8c5b36063 27
BramHeldenbergh 0:75b8c5b36063 28 SimplyLog::Log::i("Creating NeoPixel String\r\n");
BramHeldenbergh 0:75b8c5b36063 29 NeoPixelString * first_string = NeoPixelStringFactory::createNeoPixelString(DATA_PIN, STRING_SIZE);
BramHeldenbergh 0:75b8c5b36063 30
BramHeldenbergh 0:75b8c5b36063 31 SimplyLog::Log::i("Creating I2cDevice\r\n");
BramHeldenbergh 0:75b8c5b36063 32 I2cDevice i2c(p28, p27, &settings);
BramHeldenbergh 0:75b8c5b36063 33
BramHeldenbergh 0:75b8c5b36063 34 SimplyLog::Log::i("Creating NeoPixel I2c Daemon\r\n");
BramHeldenbergh 0:75b8c5b36063 35 NeoPixelI2cDaemon neo(&i2c, LED1);
BramHeldenbergh 0:75b8c5b36063 36 neo.attachPixelString(first_string);
BramHeldenbergh 0:75b8c5b36063 37
BramHeldenbergh 0:75b8c5b36063 38 SimplyLog::Log::i("Listening in blocking mode\r\n");
BramHeldenbergh 0:75b8c5b36063 39 neo.listen(true);
BramHeldenbergh 0:75b8c5b36063 40
BramHeldenbergh 0:75b8c5b36063 41 while(1) { }
BramHeldenbergh 0:75b8c5b36063 42 }
BramHeldenbergh 0:75b8c5b36063 43