![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
dd
Dependencies: xtoff2 RF24Network mbed
Fork of xtoff3 by
main.cpp
- Committer:
- pietor
- Date:
- 2018-02-22
- Revision:
- 8:c43411433ce1
- Parent:
- 7:8515f205483b
- Child:
- 9:e14f65b8ffc2
File content as of revision 8:c43411433ce1:
/** Main.cpp Purpose: main class @author Pieter Berteloot */ #include "mbed.h" #include "Ontvanger.h" Serial pc(USBTX, USBRX); Ontvanger receive; Timer t; State2 current_state = init_state; void acitvateLed() { t.reset(); } void setCurrentState( State2 setState ) { current_state = setState; } State2 getCurrentState() { return current_state; } int main() { while(1) { receive.update(); switch (current_state) { case init_state: pc.baud(9600); pc.printf("Ontvangger: \r\n"); t.start(); state_Packet packet; payload_t payload; setCurrentState(receive_state); break; case send_state: packet.setState = State_position; bool ok = receive.write(packet); if (ok) pc.printf("ok.\n\r"); else pc.printf("failed.\n\r"); wait(0.1); setCurrentState(receive_state); break; case receive_state: pc.printf("");//print niet weg doen, één of andere reden werkt het dan wel if (receive.available()) { payload_t payload; payload = receive.read(); pc.printf("%f\r\n", payload.milligram); if (payload.reedsensor) { acitvateLed(); } } if (t.read() <= 1) myled1 = myled2 = myled3 = myled4 = 1; else myled1 = myled2 = myled3 = myled4 = 0; if(pc.readable()) { char c = pc.getc(); if(c == 's') setCurrentState(send_state); wait(0.5); } break; } } }