Commit eb448a35 authored by Mart Lubbers's avatar Mart Lubbers

Merge branch 'master' of gitlab.science.ru.nl:mlubbers/mTask

parents f48ba482 f89b5f84
Pipeline #40887 passed with stages
in 11 minutes and 36 seconds
......@@ -247,9 +247,9 @@ CCS811 airqualitySensor(0);
bool airqualitysensor_init(uint8_t addr) {
airqualitySensor.~CCS811();
new (&airqualitySensor) CCS811(addr);
CCS811Core::CCS811_Status_e stat = airqualitySensor.beginWithStatus();
msg_log(airqualitySensor.statusString(stat));
return stat;
CCS811Core::CCS811_Status_e stat = airqualitySensor.beginWithStatus();
msg_log(airqualitySensor.statusString(stat));
return true;
}
void set_environmental_data(float humid, float temp, uint8_t addr) {
......@@ -334,10 +334,10 @@ void real_setup(void)
Serial.println("Have DHT");
#endif
#ifdef HAVE_AIRQUALITYSENSOR
Serial.println("Have AQS");
Serial.println("Have AQS");
#endif
#ifdef HAVE_LIGHTSENSOR
Serial.println("Have Lightsensor");
Serial.println("Have Lightsensor");
#endif
int ssid = -1;
do {
......@@ -432,11 +432,11 @@ void real_yield(void)
{
#ifdef ARDUINO_ARCH_ESP8266
yield();
if (millis()-lastping > 300) {
write_byte(MTFPING);
write_byte('\n');
lastping = millis();
}
if (millis()-lastping > 300) {
write_byte(MTFPING);
write_byte('\n');
lastping = millis();
}
#endif
}
......
......@@ -96,7 +96,7 @@ void real_loop(void)
}
#endif
real_yield();
real_yield();
read_message();
mem_gc();
......
......@@ -596,14 +596,14 @@ bool interpret(uint8_t *program, uint16_t pc, uint16_t sp, uint16_t *stack)
#ifdef HAVE_DHT
case BCDHTTEMP:
{
msg_debug(SC("Read dht temp %d\n"), stack[sp-1]);
msg_debug(SC("Read dht temp %d\n"), program[pc]);
dhttemp_data *data = NODE_DATA(tt, dhttemp_data);
data->dhttemp = program[pc++];
break;
}
case BCDHTHUMID:
{
msg_debug(SC("Read dht humid %d\n"), stack[sp-1]);
msg_debug(SC("Read dht humid %d\n"), program[pc]);
dhthumid_data *data = NODE_DATA(tt, dhthumid_data);
data->dhthumid = program[pc++];
break;
......
......@@ -559,7 +559,7 @@ uint16_t *rewrite(struct tasktree *t, uint8_t *program, uint16_t *stack)
NODE_DATA(t, dhthumid_data)->dhthumid);
b = task_peripheral(BCDHT, NODE_DATA(t, dhthumid_data)->dhthumid);
*stack++ = MT_UNSTABLE;
tfloat = get_dht_humidity(translate_pin(b[0]+b[1]), b[2]);
tfloat = get_dht_humidity(translate_pin(b[0]*256+b[1]), b[2]);
*stack++ = float2uint32_t(tfloat) >> 16;
*stack++ = float2uint32_t(tfloat) & 0xffff;
break;
......
......@@ -197,7 +197,7 @@ void task_register(void)
//Pin
bc[i++] = read_byte();
bc[i++] = read_byte();
//DHTtype
//Pin
bc[i++] = read_byte();
bc[i++] = read_byte();
msg_debug(SC("init matrix with pin %u and %u\n"),
......@@ -268,20 +268,20 @@ uint8_t *task_peripheral(uint8_t type, uint8_t index)
uint8_t *p = TASK_PER(current_task);
uint8_t ci = 0;
for (uint8_t i = 0; i<current_task->peripherals; i++) {
switch (p[i]) {
switch (p[i++]) {
case BCDHT:
if (type == p[i]) {
if (type == p[i-1]) {
if (index == ci)
return p+i+1;
return p+i;
else
ci++;
}
i+=3;
break;
case BCLEDMATRIX:
if (type == p[i]) {
if (type == p[i-1]) {
if (index == ci)
return p + i + 1;
return p + i;
else
ci++;
}
......@@ -291,15 +291,16 @@ uint8_t *task_peripheral(uint8_t type, uint8_t index)
case BCAIRQUALITYSENSOR:
case BCLIGHTSENSOR:
case BCI2CBUTTON:
if (type == p[i]) {
if (type == p[i-1]) {
if (index == ci)
return p + i + 1;
return p + i;
else
ci++;
}
i++;
i+=1;
break;
default:
msg_debug(SC("Unknown peripheral type"));
break;
}
}
......@@ -401,10 +402,12 @@ void tasktree_print_node(struct tasktree *t)
break;
#ifdef HAVE_DHT
case BCDHTTEMP:
msg_debug(SC("BCDhttemp"));
msg_debug(SC("BCDhttemp %u"),
NODE_DATA(t, dhttemp_data)->dhttemp);
break;
case BCDHTHUMID:
msg_debug(SC("BCDhthumid"));
msg_debug(SC("BCDhthumid %u"),
NODE_DATA(t, dhthumid_data)->dhthumid);
break;
#endif
#ifdef HAVE_AIRQUALITYSENSOR
......@@ -620,6 +623,11 @@ uint16_t tasktree_clone(uint16_t treep, uint16_t rptr)
*new = *tree;
new->ptr = rptr;
// Copy data
for (uint8_t i = 0; i < NODE_DATA_SIZE(tree); i++) {
NODE_DATA(new, uint8_t)[i] = NODE_DATA(tree, uint8_t)[i];
}
//Safe clone
#define CLONE(to, source) {\
to = tasktree_clone(source, newp);\
......@@ -675,12 +683,6 @@ uint16_t tasktree_clone(uint16_t treep, uint16_t rptr)
CLONE(NODE_DATA(new, sdsset_data)->data,
NODE_DATA(tree, sdsset_data)->data);
break;
case BCDELAY:
NODE_DATA(new, delay_data)->delay = NODE_DATA(tree, delay_data)->delay;
break;
case BCDELAYUNTIL:
NODE_DATA(new, until_data)->until = NODE_DATA(tree, until_data)->until;
break;
default:
break;
}
......
......@@ -106,7 +106,7 @@ struct tasktree {
uint8_t padding[3];
#endif
//Could be any type should be cast to a struct in tree_nodes.h
//uint8_t data[];
uint8_t data[];
};
struct task *task_head(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment