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 1:7a2ec350cdf5, committed 2013-08-21
- Comitter:
- vsluiter
- Date:
- Wed Aug 21 17:14:08 2013 +0000
- Parent:
- 0:cde34c55fa20
- Child:
- 2:d2f8772a8db5
- Commit message:
- Added 'WinLoose' to show who's won / lost
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Aug 21 16:52:51 2013 +0000
+++ b/main.cpp Wed Aug 21 17:14:08 2013 +0000
@@ -5,26 +5,12 @@
void Randomblinks(float seconds, bool colored = false);
void PaddleDemo(float seconds, uint8_t red, uint8_t green, uint8_t blue);
-
+void WinLoose(float seconds, bool side);
+void UpdatePaddle(void);
uint16_t totalstrip[NUMBER_OF_PIXELS];
volatile int8_t paddlestart= 0;
SPI ledstrip(PTD2,NC,PTD1);
-void UpdatePaddle(void)
-{
- static uint8_t direction = 1;
- if(direction) {
- paddlestart++;
- } else {
- paddlestart--;
- }
-
- if(paddlestart > (NUMBER_OF_PIXELS - PADDLE_LENGTH))
- direction = 0;
- if(paddlestart < 0)
- direction = 1;
-
-}
void UpdateLEDstrip(void)
{
@@ -57,11 +43,41 @@
write_led(&totalstrip[ledcounter], 0,0,0);
}
while(1) {
- PaddleDemo(5,255,10,100);
+ PaddleDemo(2,255,10,100);
+ WinLoose(3, true);
Randomblinks(5, true);
+ WinLoose(3, false);
}
}
+void WinLoose(float seconds, bool side)
+{
+ uint8_t ledcounter;
+ Timer timer;
+ timer.start();
+ while( timer.read() < seconds)
+ {
+ uint8_t redvalue = 255-(255.0*(timer.read()/(seconds/2)));
+ for(ledcounter = 0; ledcounter < NUMBER_OF_PIXELS; ledcounter++)
+ {
+ if(ledcounter < NUMBER_OF_PIXELS / 2)
+ {
+ if(side)
+ write_led(&totalstrip[ledcounter], redvalue,0,0);
+ else
+ write_led(&totalstrip[ledcounter], 0,255,0);
+ }
+ else
+ {
+ if(side)
+ write_led(&totalstrip[ledcounter], 0,255,0);
+ else
+ write_led(&totalstrip[ledcounter], redvalue ,0,0);
+
+ }
+ }
+ }
+}
void PaddleDemo(float seconds, uint8_t red, uint8_t green, uint8_t blue)
{
uint8_t ledcounter;
@@ -103,6 +119,21 @@
}
}
+void UpdatePaddle(void)
+{
+ static uint8_t direction = 1;
+ if(direction) {
+ paddlestart++;
+ } else {
+ paddlestart--;
+ }
+
+ if(paddlestart > (NUMBER_OF_PIXELS - PADDLE_LENGTH))
+ direction = 0;
+ if(paddlestart < 0)
+ direction = 1;
+}
+
//DigitalOut myled(LED1);
//int main() {