Maček Dorijan Miljković Dominik Napon i temperatura sa istog slave-a
Dependencies: Display1602 mbed-rtos mbed nRF24L01P
Revision 2:d0f85a573b89, committed 2016-01-27
- Comitter:
- DorijanMacek
- Date:
- Wed Jan 27 20:17:31 2016 +0000
- Parent:
- 1:0f605b9eed83
- Child:
- 3:07d5ce3c32e3
- Commit message:
- pa ovo radi :D
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jan 27 18:18:00 2016 +0000
+++ b/main.cpp Wed Jan 27 20:17:31 2016 +0000
@@ -4,6 +4,9 @@
#include "Display1602.h"
Mutex stdio_mutex;
+Semaphore semMSP430G(1);
+Semaphore semLCD(1);
+Semaphore semJoystick(1);
I2C MSP430G(p9, p10); //sda, sc1
@@ -46,9 +49,7 @@
int testT=0;
int testY=0;
-Semaphore semMSP430G(1);
-Semaphore semLCD(1);
-Semaphore semJoystick(1);
+
int main()
{
@@ -60,31 +61,32 @@
startNRF(transfer_size);
wait(1);
- //Thread t0(readJoystick, (void *)"readJoystick");
- //Thread t1(readTempFromMSP430G, (void *)"readTemp");
+ Thread t0(readJoystick, (void *)"readJoystick");
+ Thread t1(readTempFromMSP430G, (void *)"readTemp");
////Thread t2(readVoltFromMSP430G, (void *)"readVoltage");
- //Thread t3(printTempAndVoltOnLCD, (void *)"printTemp");
- //Thread t4(printJoystickOnLCD, (void *)"printJoytick");
+ Thread t3(printTempAndVoltOnLCD, (void *)"printTemp");
+ Thread t4(printJoystickOnLCD, (void *)"printJoytick");
- while(1){
+
//Thread t0(readJoystick, (void *)"readJoystick");
//Thread t1(readTempFromMSP430G, (void *)"readTemp");
//Thread t2(readVoltFromMSP430G, (void *)"readVoltage");
//Thread t3(printTempAndVoltOnLCD, (void *)"printTemp");
//Thread t4(printJoystickOnLCD, (void *)"printJoytick");
- printTempAndVoltOnLCD((void *)"printemAndVolt");
- printJoystickOnLCD((void *)"printjoystick");
- readJoystick((void *)"readJoystick");
- readTempFromMSP430G((void *)"readTemp");
+ //printTempAndVoltOnLCD((void *)"printemAndVolt");
+ //printJoystickOnLCD((void *)"printjoystick");
+ //readJoystick((void *)"readJoystick");
+ //readTempFromMSP430G((void *)"readTemp");
//readVoltFromMSP430G((void *)"readVoltage");
//Thread printOnLCD(temp,volt,1);
//Thread t2(test_thread, (void *)"Th 2");
- }
+
+ while(1){}
}
@@ -157,9 +159,9 @@
void printTempAndVoltOnLCD(void const *args)
{
- //while(true)
- //{
- semLCD.wait(1);
+ while(true)
+ {
+ semLCD.wait();
int znakgore=30;
int znakdolje=31;
@@ -175,14 +177,14 @@
Thread::wait(1000);
semLCD.release();
- //}
+ }
}
void printJoystickOnLCD(void const *args)
{
- //while(true)
- //{
- semLCD.wait(1);
+ while(true)
+ {
+ semLCD.wait();
display.SetXY(0,0);
display.printf("Up %.2f ",velocity);
@@ -193,16 +195,16 @@
Thread::wait(1000);
semLCD.release();
- //}
+ }
}
void readJoystick(void const *args)
{
- //while(true)
- //{
- semJoystick.wait(1);
+ while(true)
+ {
+ semJoystick.wait();
velocity=upDown;
direction =leftRight;
@@ -210,15 +212,15 @@
Thread::wait(50);
semJoystick.release();
- //}
+ }
}
void readTempFromMSP430G(void const *args)
{
- //while(true)
- //{
- semMSP430G.wait(1);
+ while(true)
+ {
+ semMSP430G.wait();
char config_t[2]; // transmitt buffer
char value_read[2]; // read buffer
config_t[0] = 0xC0; //config slave to int temp
@@ -234,15 +236,15 @@
Thread::wait(500);
semMSP430G.release();
- //}
+ }
}
void readVoltFromMSP430G(void const *args)
{
- //while(true)
- //{
- semMSP430G.wait(1);
+ while(true)
+ {
+ semMSP430G.wait();
char config_t[2]; // transmitt buffer
char value_read[2]; // read buffer
@@ -258,5 +260,5 @@
pc.printf("readVoltFromMSP430G \n\r ");
Thread::wait(500);
semMSP430G.release();
- //}
+ }
}
\ No newline at end of file