//========================================================= // LPC1114 Project //========================================================= // File Name : main.c // Function : Main Routine //--------------------------------------------------------- // Rev.01 2010.08.01 Munetomo Maruyama //--------------------------------------------------------- // Copyright (C) 2010-2011 Munetomo Maruyama //========================================================= // ---- License Information ------------------------------- // Anyone can FREELY use this code fully or partially // under conditions shown below. // 1. You may use this code only for individual purpose, // and educational purpose. // Do not use this code for business even if partially. // 2. You should use this code under the GNU GPL. // 3. You should remain this header text in your codes // including Copyright credit and License Information. // 4. Your codes should inherit this license information. //========================================================= // ---- Patent Notice ------------------------------------- // I have not cared whether this system (hw + sw) causes // infringement on the patent, copyright, trademark, // or trade secret rights of others. You have all // responsibilities for determining if your designs // and products infringe on the intellectual property // rights of others, when you use technical information // included in this system for your business. //========================================================= // ---- Disclaimers --------------------------------------- // The function and reliability of this system are not // guaranteed. They may cause any damages to loss of // properties, data, money, profits, life, or business. // By adopting this system even partially, you assume // all responsibility for its use. //========================================================= //=======Change Log======================================== //--------------------------------------------------------- // OLED Array Rev1.0 2011.05.06 hibitame //--------------------------------------------------------- #ifdef __USE_CMSIS #include "LPC11xx.h" #endif #include "array_com.h" #include "color_led.h" #include "oled.h" #include "systick.h" #include "uart.h" //================= // Define Colors //================= #define LED_ARRAY_BLK 0 #define LED_ARRAY_RED 1 #define LED_ARRAY_GRN 2 #define LED_ARRAY_ORG 3 //=============================== // OLED Array with Synchronization //=============================== //----------------------- // Draw OLED Array //----------------------- void DrawArray(uint32_t x_array,uint32_t y_array,uint32_t color) { const uint32_t COLOR_RED = (0x1f<<11)+(0x18<<5)+(0x08<<0); const uint32_t COLOR_GREEN = (0x15<<11)+(0x3f<<5)+(0x05<<0); const uint32_t COLOR_ORANGE = (0x1f<<11)+(0x35<<5)+(0x00<<0); const uint32_t COLOR_WHITE = 0xC618; uint32_t color_pixel; uint32_t offset_x,offset_y; offset_x = x_array * 16; offset_y =y_array * 16; // // Set Color // switch (color) { case LED_ARRAY_BLK: color_pixel = COLOR_WHITE; break; case LED_ARRAY_RED: color_pixel = COLOR_RED; break; case LED_ARRAY_ORG: color_pixel = COLOR_ORANGE; break; case LED_ARRAY_GRN: color_pixel = COLOR_GREEN; break; } // // Draw ARRAY LED // //upper OLED_Fill_Rect(offset_x +6, offset_y + 1,4,1,color_pixel); OLED_Fill_Rect(offset_x +4, offset_y + 2,8,1,color_pixel); //center OLED_Fill_Rect(offset_x +3, offset_y + 3,10,10,color_pixel); //bottom OLED_Fill_Rect(offset_x +4, offset_y + 13,8,1,color_pixel); OLED_Fill_Rect(offset_x +6, offset_y + 14,4,1,color_pixel); //left OLED_Fill_Rect(offset_x +1, offset_y + 6,1,4,color_pixel); OLED_Fill_Rect(offset_x +2, offset_y + 4,1,8,color_pixel); //right OLED_Fill_Rect(offset_x +13, offset_y + 4,1,8,color_pixel); OLED_Fill_Rect(offset_x +14, offset_y + 6,1,4,color_pixel); } //------------------------ // Draw OLED Array (a Demo) //------------------------ void Draw_LED_Array(void) { uint32_t x, y; uint32_t color; uint32_t scene; uint32_t step; uint32_t baudrate = 9600; UARTInit(baudrate); static uint32_t prev_step = 0; step = (Get_Ticks() >> 3); if (step > prev_step) { prev_step = step; // for (y = 0; y < 4; y++) for (x = 0; x < 4; x++) { scene = (((step / 8) & 0x01) == 0)? 7 - (step & 0x07) : (step & 0x07); color = ((x + y + 1) == scene)? (step / 16) : LED_ARRAY_BLK; color = color & 0x03; DrawArray( x, y, color); DrawArray(7-x, y, color); DrawArray(x, 7-y, color); DrawArray(7-x, 7-y, color); } } } //----------------------- // Main Routine //----------------------- int main(void) { uint32_t tick_curr; uint32_t tick_sync_intv; uint32_t tick_sync_intv_prev = 0; // // Initialization // Init_SysTick(); Init_Array_COM(); Array_COM_ID_Assignment(); Init_Color_LED(); Init_OLED(); // // Main Loop // while(1) { // // Draw LEDs // //Draw_Color_LED(); Draw_LED_Array(); // // Do Array Sync // tick_curr = Get_Ticks(); tick_sync_intv = tick_curr - tick_sync_intv_prev; if (tick_sync_intv > 128) // 1.28sec { tick_sync_intv_prev = (tick_curr / 128) * 128; // // Do Sync with Adjacent Block // Sync_Ticks_Tx(S); // South Sync_Ticks_Tx(E); // East } } return 0; } //========================================================= // End of Program //=========================================================