Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposer.ino #13

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}

}