Created
July 18, 2016 05:21
-
-
Save monpetit/fae0779a4bd617cc9a77262362ffb36c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mbed.h" | |
#include "LCD_DISCO_F429ZI.h" | |
#include "TrueRandom.h" | |
#define MAX(a, b) ((a >= b) ? a : b) | |
#define MIN(a, b) ((a < b) ? a : b) | |
#define LCD_WIDTH 240 | |
#define LCD_HEIGHT 320 | |
LCD_DISCO_F429ZI lcd; | |
DigitalOut led1(LED1); | |
TrueRandom tr(PC_1); | |
uint32_t color_table[25] = { | |
LCD_COLOR_BLUE , | |
LCD_COLOR_GREEN , | |
LCD_COLOR_RED , | |
LCD_COLOR_CYAN , | |
LCD_COLOR_MAGENTA , | |
LCD_COLOR_YELLOW , | |
LCD_COLOR_LIGHTBLUE , | |
LCD_COLOR_LIGHTGREEN , | |
LCD_COLOR_LIGHTRED , | |
LCD_COLOR_LIGHTCYAN , | |
LCD_COLOR_LIGHTMAGENTA , | |
LCD_COLOR_LIGHTYELLOW , | |
LCD_COLOR_DARKBLUE , | |
LCD_COLOR_DARKGREEN , | |
LCD_COLOR_DARKRED , | |
LCD_COLOR_DARKCYAN , | |
LCD_COLOR_DARKMAGENTA , | |
LCD_COLOR_DARKYELLOW , | |
LCD_COLOR_WHITE , | |
LCD_COLOR_LIGHTGRAY , | |
LCD_COLOR_GRAY , | |
LCD_COLOR_DARKGRAY , | |
LCD_COLOR_BLACK , | |
LCD_COLOR_BROWN , | |
LCD_COLOR_ORANGE , | |
}; | |
int main(void) | |
{ | |
uint32_t color; | |
int x1, x2, y1, y2; | |
int x, y, w, h; | |
led1 = 1; | |
lcd.Clear(LCD_COLOR_BLACK); | |
lcd.SetBackColor(LCD_COLOR_BLACK); | |
wait(1.0); | |
#define COUNT_LIMIT 10000 | |
while (1) { | |
lcd.Clear(LCD_COLOR_BLACK); | |
for (int px = 0; px < LCD_WIDTH; px++) { | |
for (int py = 0; py < LCD_HEIGHT; py++) { | |
lcd.DrawPixel(px, py, tr.random()); | |
} | |
} | |
wait(1.0); | |
lcd.Clear(LCD_COLOR_BLACK); | |
for (int i = 0; i < COUNT_LIMIT * 2; i++) { | |
color = color_table[tr.random(25)]; | |
// lcd.SetTextColor(color); | |
lcd.DrawPixel(tr.random(LCD_WIDTH), tr.random(LCD_HEIGHT), color); | |
} | |
wait(1.0); | |
lcd.Clear(LCD_COLOR_BLACK); | |
for (int i = 0; i < COUNT_LIMIT; i++) { | |
color = color_table[tr.random(25)]; | |
lcd.SetTextColor(color); | |
lcd.DrawLine(tr.random(LCD_WIDTH), tr.random(LCD_HEIGHT), tr.random(LCD_WIDTH), tr.random(LCD_HEIGHT)); | |
} | |
wait(1.0); | |
lcd.Clear(LCD_COLOR_BLACK); | |
for (int i = 0; i < COUNT_LIMIT; i++) { | |
color = color_table[tr.random(25)]; | |
lcd.SetTextColor(color); | |
x1 = tr.random(LCD_WIDTH); | |
x2 = tr.random(LCD_WIDTH); | |
y1 = tr.random(LCD_HEIGHT); | |
y2 = tr.random(LCD_HEIGHT); | |
x = MIN(x1, x2); | |
y = MIN(y1, y2); | |
w = MAX(x1, x2) - x; | |
h = MAX(y1, y2) - y; | |
if ((w > 2) && (h > 2)) | |
lcd.FillRect(x, y, w, h); | |
} | |
wait(1.0); | |
lcd.Clear(LCD_COLOR_BLACK); | |
for (int i = 0; i < COUNT_LIMIT / 7; i++) { | |
color = color_table[tr.random(25)]; | |
lcd.SetTextColor(color); | |
lcd.FillTriangle(tr.random(LCD_WIDTH), | |
tr.random(LCD_WIDTH), | |
tr.random(LCD_WIDTH), | |
tr.random(LCD_HEIGHT), | |
tr.random(LCD_HEIGHT), | |
tr.random(LCD_HEIGHT)); | |
} | |
lcd.Clear(LCD_COLOR_BLACK); | |
wait(1.0); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment