Liam Grazier
/
0NicksCoursework-lg
diajzifsajoifajsoifaj
Fork of ELEC350-CWTEMPLATE-2017 by
main.cpp@7:dd303488e55d, 2018-01-07 (annotated)
- Committer:
- liam_grazier
- Date:
- Sun Jan 07 21:29:12 2018 +0000
- Revision:
- 7:dd303488e55d
- Parent:
- 6:f0601ebd2423
working LCD, SD, (NON FIFO) , webpage, all threaded
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
liam_grazier | 5:9b4844128e09 | 1 | #include "components.hpp" |
liam_grazier | 5:9b4844128e09 | 2 | #include "mbed.h" |
liam_grazier | 7:dd303488e55d | 3 | #include "network.hpp" |
liam_grazier | 5:9b4844128e09 | 4 | #include "lglcd.h" |
liam_grazier | 7:dd303488e55d | 5 | InterruptIn sw1(USER_BUTTON); |
liam_grazier | 7:dd303488e55d | 6 | Thread samplesThread(osPriorityNormal); |
liam_grazier | 7:dd303488e55d | 7 | Thread sdThread(osPriorityLow); |
liam_grazier | 7:dd303488e55d | 8 | Thread sdRemoveThread(osPriorityLow); |
liam_grazier | 7:dd303488e55d | 9 | //Thread rtThread; |
liam_grazier | 7:dd303488e55d | 10 | //Thread stxThread; |
liam_grazier | 7:dd303488e55d | 11 | Thread netThread(osPriorityRealtime); |
liam_grazier | 7:dd303488e55d | 12 | void inter1(); |
liam_grazier | 7:dd303488e55d | 13 | void inter2(); |
liam_grazier | 7:dd303488e55d | 14 | void inter3(); |
liam_grazier | 7:dd303488e55d | 15 | void inter4(); |
noutram | 3:a88838ff33e7 | 16 | // This is a very short demo that demonstrates all the hardware used in the coursework. |
noutram | 3:a88838ff33e7 | 17 | // You will need a network connection set up (covered elsewhere). The host PC should have the address 10.0.0.1 |
liam_grazier | 7:dd303488e55d | 18 | Ticker samples; |
liam_grazier | 7:dd303488e55d | 19 | Ticker remov; |
liam_grazier | 7:dd303488e55d | 20 | InterruptIn sdex(USER_BUTTON); |
liam_grazier | 7:dd303488e55d | 21 | Ticker storage; |
liam_grazier | 7:dd303488e55d | 22 | Ticker netTick; |
liam_grazier | 7:dd303488e55d | 23 | void inter1(){ |
liam_grazier | 7:dd303488e55d | 24 | sdcheck(); |
liam_grazier | 7:dd303488e55d | 25 | samplesThread.signal_set(SIG_READY); |
liam_grazier | 7:dd303488e55d | 26 | } |
liam_grazier | 7:dd303488e55d | 27 | void inter2(){ |
liam_grazier | 7:dd303488e55d | 28 | sdThread.signal_set(SIG_READY2); |
liam_grazier | 7:dd303488e55d | 29 | } |
liam_grazier | 7:dd303488e55d | 30 | void inter3(){ |
liam_grazier | 7:dd303488e55d | 31 | printf("CHECK REMOVE BUTTON\n\r"); |
liam_grazier | 7:dd303488e55d | 32 | if(sdex == 1){ |
liam_grazier | 7:dd303488e55d | 33 | sdRemoveThread.signal_set(SIG_REMOVE); |
liam_grazier | 7:dd303488e55d | 34 | } |
liam_grazier | 7:dd303488e55d | 35 | } |
liam_grazier | 7:dd303488e55d | 36 | void inter4(){ |
liam_grazier | 7:dd303488e55d | 37 | netThread.signal_set(SIG_NET); |
liam_grazier | 7:dd303488e55d | 38 | } |
liam_grazier | 5:9b4844128e09 | 39 | int main(){ |
liam_grazier | 7:dd303488e55d | 40 | sdrun(); |
liam_grazier | 5:9b4844128e09 | 41 | lglcd mylcd(D7,D6,D5,D4,D3,D2); |
liam_grazier | 5:9b4844128e09 | 42 | mylcd.clear(); |
liam_grazier | 7:dd303488e55d | 43 | sdThread.start(sdwrite); |
liam_grazier | 7:dd303488e55d | 44 | storage.attach(&inter2,10); //runs send to sd based on last number (5) in this case (every 5 seconds) |
liam_grazier | 7:dd303488e55d | 45 | samplesThread.start(runanalysis); |
liam_grazier | 7:dd303488e55d | 46 | samples.attach(&inter1,1); //runs analysis based on last number (1) in this case (every 1 second) |
liam_grazier | 7:dd303488e55d | 47 | sdRemoveThread.start(sdremove); |
liam_grazier | 7:dd303488e55d | 48 | remov.attach(&inter3,3);//checks sd remove key every second |
liam_grazier | 7:dd303488e55d | 49 | netThread.start(networksend); |
liam_grazier | 7:dd303488e55d | 50 | netTick.attach(&inter4,0.01); |
noutram | 0:36e89e3ed7c4 | 51 | |
noutram | 1:e1cf7663f5ff | 52 | |
liam_grazier | 7:dd303488e55d | 53 | |
liam_grazier | 7:dd303488e55d | 54 | } |