Skip to content

Commit

Permalink
Exposer.ino
Browse files Browse the repository at this point in the history
Update example with some signals

Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric committed Nov 14, 2016
1 parent b982e43 commit 321d0de
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions Exposer.ino
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
#include "exposer.h"
#include <math.h>

// Declare exposer
Exposer* exposer = &Exposer::self();

uint8_t led = 0;
const float ppi = 2*M_PI;

// Create some variables
uint8_t led = 0;
uint8_t testuint8 = 0;
uint16_t testuint16 = 0;
uint32_t testuint32 = 0;
int8_t testint8 = 0;
int16_t testint16 = 0;
int32_t testint32 = 0;
float testfloat = 0;
static float testfloat = 1.11;
String teststring = "Batata";

unsigned long next;

void setup()
{
// Hardware initialization
Serial.begin(115200);
pinMode(13, OUTPUT);


exposer->registerVariable(VARNAME(led), Exposer::_uint8_t, &led);
exposer->registerVariable(VARNAME(testuint8), Exposer::_uint8_t, &testuint8);
exposer->registerVariable(VARNAME(testuint16), Exposer::_uint16_t, &testuint16);
Expand All @@ -34,12 +41,33 @@ void setup()

void loop()
{
// Get actual time
unsigned int now = millis();

digitalWrite(13,(testint8==-50));
// Create omega
float w0 = ppi*now/100;
float w1 = ppi*now/1000;
float w2 = ppi*now/2000;
float w3 = ppi*now/3000;
float w4 = ppi*now/4000;

// Update variables
led = now/100;
testuint8 = 100*(sin(w1) + 1);
testuint16 = 100*(sin(w2 + ppi/4) + 1);
testuint32 = 100*(sin(w3 - ppi/4) + 1);
testint8 = 100*sin(w1);
testint16 = 100*sin(w2 + ppi/4);
testint32 = 100*sin(w3 - ppi/4);
testfloat = atan(testint8)*30;

digitalWrite(13, (testint8 > 124));

// Run exposer
exposer->update();

if (millis()>next){
// Write something in serial monitor
if (now>next){
Serial.print("uint8:");Serial.println(testuint8);
Serial.print("uint16:");Serial.println(testuint16);
Serial.print("uint32:");Serial.println(testuint32);
Expand All @@ -48,8 +76,9 @@ void loop()
Serial.print("int32:");Serial.println(testint32);
Serial.print("float:");Serial.println(testfloat);
Serial.print("string:");Serial.println(teststring);

// Write something in 1s
next = millis()+1000;
}

}

0 comments on commit 321d0de

Please sign in to comment.