RoboCup Base Station
Dependencies: mbed mbed-rtos Wireless Drivers
Diff: main.cpp
- Revision:
- 4:ec95917c3211
- Parent:
- 3:c3114df544e8
diff -r c3114df544e8 -r ec95917c3211 main.cpp --- a/main.cpp Wed Dec 31 09:32:08 2014 +0000 +++ b/main.cpp Wed Dec 31 22:16:17 2014 +0000 @@ -2,6 +2,8 @@ #include "BaseStation.h" +uint8_t channel; + // Function for writing a number to the 7-segment display void writeSegment(uint8_t val, DigitalOut& latch) { @@ -25,9 +27,8 @@ // Decimal point initialized to OFF DigitalOut decimal( RJ_7_SEG_DOT_PIN, 1 ); - uint8_t channel = 8; + channel = 8; writeSegment(channel, latch); - channel = 0; // start from 0 once the main task's look begins // wait to be signaled before beginning osSignalWait(0x01, osWaitForever); @@ -40,8 +41,8 @@ while(1) { // loop forever // send numerical value to 7-segment & hold for a while - writeSegment(channel++, latch); - channel = (channel > 9) ? 0 : channel; // reset value if too high + writeSegment(channel, latch); + // channel = (channel > 9) ? 0 : channel; // reset value if too high Thread::wait(1000); } } @@ -95,34 +96,45 @@ r2_led[i] = 1; } } -/* - // turn off all radio status LEDs - for (int i=0; i<3; i++) { - r1_led[i] = 1; - r2_led[i] = 1; - Thread::wait(50); - } -*/ + // give power to all colors of the RGB LED and turn off decimal point rgb_pwr = 1; + // 915MHz band radio object + CC1101 cc1101( + RJ_SPI_PINS, + RJ_PRIMARY_RADIO_CS_PIN, + RJ_PRIMARY_RADIO_LED_TX, + RJ_PRIMARY_RADIO_LED_RX, + RJ_PRIMARY_RADIO_INT_PIN + ); + + // set pointer for base class calls + Radio *radio_p = &cc1101; + + channel = radio_p->channel(); // tell the segment thread to begin its task thread_seg_task.signal_set(0x01); - // fade the RGB LED up to green and half power + uint8_t color; + if (radio_p->hasError()) { + color = 0; + } else { + color = 1; + } + + // fade the RGB LED up to the right status color at half power for (float i=1.0; i>0.5; i-=0.01) { - rgb_led[G] = i; + rgb_led[color] = i; Thread::wait(20); } - // at led_intensity[3] = { 0, 0, 0 }; - srand(time(NULL)); + // loop forever ==================== while(1) { - uint8_t color = rand()%2; - // rgb_led[color] = (rand()%1000)/1000; + // // delay Thread::wait(300);