~

Dependencies:   mbed SimpleRGB mbed-rtos 4DGL-uLCD-SE SDFileSystem wave_player

Committer:
kswanson31
Date:
Sun Oct 09 23:30:00 2016 +0000
Revision:
0:51d88b4e2b23
Child:
1:ff69d2d97a2c
Contains complete part 1, sketch of part 2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kswanson31 0:51d88b4e2b23 1 #include "mbed.h"
kswanson31 0:51d88b4e2b23 2 #include "rtos.h"
kswanson31 0:51d88b4e2b23 3
kswanson31 0:51d88b4e2b23 4 /* 1 init/declare
kswanson31 0:51d88b4e2b23 5 Ticker first;
kswanson31 0:51d88b4e2b23 6 Ticker second;
kswanson31 0:51d88b4e2b23 7 Ticker third;
kswanson31 0:51d88b4e2b23 8 Ticker fourth;
kswanson31 0:51d88b4e2b23 9 DigitalOut led1(LED1);
kswanson31 0:51d88b4e2b23 10 DigitalOut led2(LED2);
kswanson31 0:51d88b4e2b23 11 DigitalOut led3(LED3);
kswanson31 0:51d88b4e2b23 12 DigitalOut led4(LED4);
kswanson31 0:51d88b4e2b23 13
kswanson31 0:51d88b4e2b23 14 void one() { // attached to ticker object. will be called after time given
kswanson31 0:51d88b4e2b23 15 led1 = !led1; // flip the value of the led
kswanson31 0:51d88b4e2b23 16 } // nothing returned
kswanson31 0:51d88b4e2b23 17
kswanson31 0:51d88b4e2b23 18 void two() {
kswanson31 0:51d88b4e2b23 19 led2 = !led2;
kswanson31 0:51d88b4e2b23 20 }
kswanson31 0:51d88b4e2b23 21
kswanson31 0:51d88b4e2b23 22 void three() {
kswanson31 0:51d88b4e2b23 23 led3 = !led3;
kswanson31 0:51d88b4e2b23 24 }
kswanson31 0:51d88b4e2b23 25
kswanson31 0:51d88b4e2b23 26 void fourth() {
kswanson31 0:51d88b4e2b23 27 led4 = !led4;
kswanson31 0:51d88b4e2b23 28 }
kswanson31 0:51d88b4e2b23 29 */// - 1
kswanson31 0:51d88b4e2b23 30
kswanson31 0:51d88b4e2b23 31 /* 2 init/declare */
kswanson31 0:51d88b4e2b23 32 void uLCD_reboot_thread(void const *args) {
kswanson31 0:51d88b4e2b23 33 // show reboot process, associated with clip of apple restart
kswanson31 0:51d88b4e2b23 34 while (1) {
kswanson31 0:51d88b4e2b23 35 // lock, print 'Rebooting!' to uLCD with "progress_bar" underneath
kswanson31 0:51d88b4e2b23 36 // draw progress bar 8 sec
kswanson31 0:51d88b4e2b23 37 // draw an ascii 'apple'
kswanson31 0:51d88b4e2b23 38 // unlock, wait for 52
kswanson31 0:51d88b4e2b23 39 }
kswanson31 0:51d88b4e2b23 40 }
kswanson31 0:51d88b4e2b23 41
kswanson31 0:51d88b4e2b23 42 void uLCD_status_thread(void const *args) {
kswanson31 0:51d88b4e2b23 43 // show time with smile, frown, sad face at top right
kswanson31 0:51d88b4e2b23 44 while (1) {
kswanson31 0:51d88b4e2b23 45 // lock, update time at top right with smiley at top left
kswanson31 0:51d88b4e2b23 46 // unlock, wait for 20 sec
kswanson31 0:51d88b4e2b23 47 // lock, change to frown
kswanson31 0:51d88b4e2b23 48 // unlock, wait for 20 sec
kswanson31 0:51d88b4e2b23 49 // lock, change to sad
kswanson31 0:51d88b4e2b23 50 // unlock, wait for 20 sec
kswanson31 0:51d88b4e2b23 51 }
kswanson31 0:51d88b4e2b23 52 }
kswanson31 0:51d88b4e2b23 53
kswanson31 0:51d88b4e2b23 54 void rainbow_led_thread(void const *args) {
kswanson31 0:51d88b4e2b23 55 // reboot with white, then cycle through apple rainbow colors
kswanson31 0:51d88b4e2b23 56 while (1) {
kswanson31 0:51d88b4e2b23 57 // bright white, dim to nothing over 4 sec
kswanson31 0:51d88b4e2b23 58 // green
kswanson31 0:51d88b4e2b23 59 // yellow
kswanson31 0:51d88b4e2b23 60 // orange
kswanson31 0:51d88b4e2b23 61 // red
kswanson31 0:51d88b4e2b23 62 // purple
kswanson31 0:51d88b4e2b23 63 // blue
kswanson31 0:51d88b4e2b23 64 }
kswanson31 0:51d88b4e2b23 65 }
kswanson31 0:51d88b4e2b23 66 // - 2
kswanson31 0:51d88b4e2b23 67
kswanson31 0:51d88b4e2b23 68 int main() {
kswanson31 0:51d88b4e2b23 69 /* 1 calls
kswanson31 0:51d88b4e2b23 70 led1 = 1, led2 = 1, led3 = 1, led4 = 1;
kswanson31 0:51d88b4e2b23 71
kswanson31 0:51d88b4e2b23 72 first.attach(&one, 1.0); // attach the function and when to call it
kswanson31 0:51d88b4e2b23 73 second.attach(&two, 2.0);
kswanson31 0:51d88b4e2b23 74 third.attach(&three, 3.0);
kswanson31 0:51d88b4e2b23 75 fourth.attach(&four, 4.0);
kswanson31 0:51d88b4e2b23 76 */// - 1
kswanson31 0:51d88b4e2b23 77
kswanson31 0:51d88b4e2b23 78 while(1) {
kswanson31 0:51d88b4e2b23 79 /* 2 speaker 'thread' calls */
kswanson31 0:51d88b4e2b23 80 // speaker plays mac reboot sound, error sound occasionally
kswanson31 0:51d88b4e2b23 81 // play reboot sound
kswanson31 0:51d88b4e2b23 82 // wait 20
kswanson31 0:51d88b4e2b23 83 // error
kswanson31 0:51d88b4e2b23 84 // wait 20
kswanson31 0:51d88b4e2b23 85 // error
kswanson31 0:51d88b4e2b23 86 // wait 20
kswanson31 0:51d88b4e2b23 87 } // interupts will occur automatically
kswanson31 0:51d88b4e2b23 88 }