This is a driver for a project I made in school. It involves a Raspberry Pi connected to the MBED, which in turn is connected to a Ledcube. The MBED delivers data for the leds to the Ledcube continuously at a 100 Hz rate, using SPI. This data is read from an internal buffer. For animations, the Raspberry Pi just sends data when the current "image" has to change, using I2C.
LedCube.h
00001 #include "iostream" 00002 #include "mbed.h" 00003 #ifndef LedCube_h 00004 #define LedCube_h 00005 enum Color_led { l_red, l_green, l_blue }; 00006 class LedCube{ 00007 private: 00008 unsigned char rValues[8][8] ; 00009 unsigned char gValues[8][8]; 00010 unsigned char bValues[8][8]; 00011 00012 //indexes 00013 int x_current; 00014 int y_current; 00015 int z_current; 00016 00017 enum{address,red,green,blue} status; 00018 int layer_current; 00019 int rank_current; 00020 00021 unsigned char layer_oneHot; 00022 00023 public: 00024 LedCube(); 00025 unsigned char getNextValue(); 00026 void setData(unsigned char* data); 00027 void printValues(Color_led color); 00028 void printAll(); 00029 }; 00030 #endif
Generated on Thu Aug 25 2022 12:14:09 by
1.7.2