Version 8, working version with Alix, sams and ollies code. Displays time, date and sensor info onto terminal, LCD and networking, and saves onto SD card.

Dependencies:   BMP280 ELEC350-Practicals-FZ429 TextLCD BME280 ntp-client

Revision:
5:f87129ac8bf3
Parent:
4:740cba3f2716
Child:
6:b7f6e0c0f646
--- a/Sampler.hpp	Tue Nov 27 12:51:34 2018 +0000
+++ b/Sampler.hpp	Thu Nov 29 16:08:28 2018 +0000
@@ -1,88 +1,43 @@
+#ifndef _SAMPLER_
+#define _SAMPLER_
+#include "message.hpp"
 #include "mbed.h"
+#include "LCD.hpp"
 #define Activate_Flag 1
 
-// Class for Sampled Data
-class sample_message 
-{
-public:
-    float temp;
-    float pressure;
-    int sw1State;
-    int sw2State;
-    sample_message(float f1, float f2, int s1, int s2)
-    {
-        temp = f1;
-        pressure = f2;
-        sw1State = s1;
-        sw2State = s2;
-    }
-};
-
-class MailQueue     
-// Potentially place all of the mail queue code into a class. Include pushing and popping functions
-// Circular buffer management also - Rewrite the oldest sample -> Include in the mail queue or in each respective thread??
-{
- private:
- 
- public:
-    
-};
+EventQueue SAMP_Queue;  //create an event queue for main
 
 class Sampler
 {
 private:
-        Thread t1;                              // Sample Thread
-        MemoryPool<sample_message, 20> mpool;        //Memory Pool has 20 data blocks
-        Queue<sample_message, 20> queue;             //Message queue
-        EventQueue sampEQueue;                        //Initialise the EventQueue
+        EventQueue sampEQueue;                  //Initialise the EventQueue
 public: 
     void publishSample()
     {
-        
+        getData();
+        m_oDisplay.LCD_Queue.call(&m_oDisplay, &LCD_Data::update_sensor_info, sample);
+        //SD_Queue.call(&m_oSD_data, &SD_Queue::update_sensor_info, sample_data, sample_data);
+        //SERIAL_Queue.call(&m_oSERIAL_data, &SERIAL_Queue::update_sensor_info, sample_data, sample_data);
     }
-    
-    void activate()
-    {
-        t1.signal_set(Activate_Flag);   // Signal the sampling thread to move from WAITING to READY
-    }
-
-    void samplingThread()
+    void getData()
     {
-        while(1)
-        {
-            Thread::signal_wait(Activate_Flag);
-            printf("\033[2J"); // Clear screen
-            printf("\033[H"); //  Home Position
-            printf("**********Sample**********\n");  
-            int sw1State = SW1.read();
-            int sw2state = SW2.read();        
-            printf("SW1: %d\tSW2: %d\n\r", sw1State, sw2state);    
-            printf("LDR: %3.5f\n\r", adcIn.read()*4095);
-            float temp = sensor.getTemperature();
-            float pressure = sensor.getPressure();
-            #ifdef BME
-            float humidity = sensor.getHumidity();
-            #endif
-            printf("Temperature: %5.1f\n", temp);
-            printf("Pressure: %5.1f\n", pressure);
-            #ifdef BME
-            printf("Pressure: %5.1f\n", humidity);
-            #endif            
-            mailqueuePush(temp, pressure, sw1State, sw2state);  // Place onto the mailqueue
-        }
+        int sw1State = SW1.read();
+        int sw2State = SW2.read();        
+        float temp = sensor.getTemperature();
+        float pressure = sensor.getPressure();
+        #ifdef BME
+        float humidity = sensor.getHumidity();
+        #endif
+        sample.temp = temp;
+        sample.pressure = pressure;
+        sample.sw1State = sw1State;
+        sample.swState = sw1State;
     }
-    Sampler() 
-    {   //Constructor 
-        osThreadId idMain;
-        osThreadId idSample;
-        idMain = osThreadGetId();               // CMSIS RTOS Call
-        idSample = t1.gettid();                 // Assign the id to the thread handle (Check this)
-        t1.start(this, &Sampler::samplingThread);               // Start the sampling thread
-        // NVIC_SetPriority(TIMER0_IRQn,osPriorityHigh);     // Uncomment for priority setting in the NVIC
+    Sampler()   //Constructor 
+    {   
     }
-    //Destructor - should the instance go out of scope, this is called
-    ~Sampler() 
+    ~Sampler() //Destructor - should the instance go out of scope, this is called
     {
-        // Code
     }
-};
\ No newline at end of file
+};
+#endif
\ No newline at end of file