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.
Revision 4:d129442ea4dd, committed 2021-10-17
- Comitter:
- reedas
- Date:
- Sun Oct 17 18:29:13 2021 +0000
- Parent:
- 3:a14b2aa7546e
- Child:
- 5:5fa081667b88
- Commit message:
- Initial Commit
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed_app.json | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Oct 16 22:44:39 2021 +0000
+++ b/main.cpp Sun Oct 17 18:29:13 2021 +0000
@@ -3,27 +3,21 @@
#include "mbed.h"
#include "GUI.h"
#include "cy8ckit_028_tft.h"
-#include "PinDetect.h"
-PinDetect pb1(SWITCH2);
-uint8 counter = 0;
-AnalogIn lightLevel(P10_0);
-Serial pc(USBTX, USBRX);
-
-// Callback routine is interrupt activated by a debounced pb1 hit
-void pb1_hit_callback (void)
-{
- counter = 0;
-}
-
-int readLightLevel() {
- int lightPercent;
- lightPercent = (lightLevel.read_u16()*100)/65535;
- return lightPercent;
- }
+#define LED_DIAMETER (16)
+#define LED_RADIUS (LED_DIAMETER/2)
+#define DISPLAY_X (320)
+#define DISPLAY_Y (240)
+#define NUMLEDS_X (DISPLAY_X/LED_DIAMETER)
+#define NUMLEDS_Y (DISPLAY_Y/LED_DIAMETER)
+#define LED_OFF (0)
+#define LED_ON (1)
+#define TITLE_OFFSET (16+LED_RADIUS)
void Display_Init(void)
{
+ /* Initialise EmWin driver*/
+ GUI_Init();
/* Set font size, foreground and background Colours */
GUI_SetFont(GUI_FONT_16B_1);
@@ -33,55 +27,40 @@
/* Clear screen and print splash screen */
GUI_Clear();
GUI_SetTextAlign(GUI_TA_HCENTER);
- GUI_DispStringAt("TFT Demo", 160, 20);
+ GUI_DispStringAt("asr666 Super Computer", 160, 0);
}
int main()
{
-
- /* Initialise EmWin driver*/
- GUI_Init();
-
/* Initialise display */
Display_Init();
- pb1.mode(PullUp);
- // Delay for initial pullup to take effect
- ThisThread::sleep_for(10);
- // Setup Interrupt callback functions for a pb hit
- pb1.attach_deasserted(&pb1_hit_callback);
- // Start sampling pb inputs using interrupts
- pb1.setSampleFrequency();
- pc.printf("tft demo\r\n");
-
+ printf("Starting Supercomputer\r\n");
GUI_SetFont(GUI_FONT_8X16X2X2);
- GUI_SetTextAlign(GUI_TA_HCENTER);
- GUI_DispStringAt("Hello World!", 160, 40);
+ GUI_SetColor(GUI_DARKGREEN);
+ uint8_t array[NUMLEDS_X][NUMLEDS_Y];
+ for (int j=0; j < NUMLEDS_Y; j++) {
+ for (int i=0; i < NUMLEDS_X; i++) {
+ array[i][j]=LED_OFF;
+ GUI_SetColor(GUI_DARKGREEN);
+ GUI_FillCircle(LED_RADIUS+(i)*LED_DIAMETER, TITLE_OFFSET+(j*LED_DIAMETER), LED_RADIUS);
+ }
+ }
while(1) {
-
- GUI_SetTextAlign(GUI_TA_HCENTER);
- GUI_DispHexAt(counter, 160, 100, 2);
- GUI_SetTextAlign(GUI_TA_HCENTER);
- GUI_DispDecAt(counter, 160, 70, 3);
- for(int pos = 0; pos < 8; pos++) {
- if ((counter >> pos & 0x01) == 1) {
- GUI_SetColor(GUI_BLUE);
- }
- else {
- GUI_SetColor(GUI_DARKBLUE);
- }
-// GUI_FillRect(208 - (16*pos), 140, 224 - (2+16 * pos), 156);
- GUI_FillCircle(216 - (16*pos), 148, 8);
+ int ledx = rand()%NUMLEDS_X;
+ int ledy = rand()%NUMLEDS_Y;
+ if (array[ledx][ledy]==LED_OFF) {
+ GUI_SetColor(GUI_GREEN);
+ GUI_FillCircle(LED_RADIUS+(ledx)*LED_DIAMETER, TITLE_OFFSET+LED_DIAMETER*(ledy), LED_RADIUS);
+ array[ledx][ledy] = LED_ON;
}
- GUI_SetColor(GUI_WHITE);
- GUI_SetTextAlign(GUI_TA_HCENTER);
- GUI_DispBinAt(counter++, 160, 160, 8);
- GUI_DispStringAt("Light is: ", 40, 200);
- GUI_DispDec(readLightLevel(), 3);
- GUI_DispString("%");
- ThisThread::sleep_for(500);
-
+ else {
+ GUI_SetColor(GUI_DARKGREEN);
+ GUI_FillCircle(LED_RADIUS+(ledx)*LED_DIAMETER, TITLE_OFFSET+LED_DIAMETER*(ledy), LED_RADIUS);
+// GUI_FillCircle(8+(ledx)*16, 24+16*(ledy), 8);
+ array[ledx][ledy] = LED_OFF;
+ }
}
}
--- a/mbed_app.json Sat Oct 16 22:44:39 2021 +0000
+++ b/mbed_app.json Sun Oct 17 18:29:13 2021 +0000
@@ -1,7 +1,10 @@
{
"config": {
"SDA":"P6_1",
- "SCL":"P6_0"
+ "SCL":"P6_0",
+ "main-stack-size": {
+ "value": 8192
+ }
},"target_overrides": {
"*": {
"SDA" : "SDA",