Great! 1200 baud, right what I needed! I succeed to parse 7n1 by using "& 0x7f".
Hopelessly there is reading errors (cf. Serial strange behaviour).
Great! 1200 baud, right what I needed! I succeed to parse 7n1 by using "& 0x7f".
Code: Select all
#define MAX_CANAUX 10
byte PinEntree[MAX_CANAUX+1];
byte ValeurEntree[MAX_CANAUX+1];
void setup()
{
for (int i=0;i<=MAX_CANAUX;i++) {
ValeurEntree[i] = FALSE;
PinEntree[i] = 0;
}
PinEntree[1] = 0;
PinEntree[2] = 1;
PinEntree[3] = 8;
PinEntree[4] = 7;
PinEntree[5] = 6;
PinEntree[6] = 5;
PinEntree[7] = 4;
PinEntree[8] = 3;
PinEntree[9] = 25;
PinEntree[10] = 9;
for (int i=1;i<=MAX_CANAUX;i++) pinMode(PinEntree[i], INPUT_PULLUP);
Serial.begin();
}
void loop()
{
for (int i=1;i<=MAX_CANAUX;i++) {
ValeurEntree[i] = digitalRead(PinEntree[i]);
delay(2);
Serial.print(ValeurEntree[i], DEC);
Serial.print(" / ");
}
Serial.println("");
}
Code: Select all
#define ZUNO_MAX_ASSOC_NUMBER 5
#define ZUNO_ADD_ASSOCIATION(TYPE) zunoAddAssociation(TYPE)
Code: Select all
void zunoAddAssociation(byte t) {
if(g_user_sketch.n_assocs > ZUNO_MAX_ASSOC_NUMBER)
return;
g_user_sketch.asociations[g_user_sketch.n_assocs] = t;
g_user_sketch.n_assocs++;
}
This new third beta is public now.
Code: Select all
ZUNO_SETUP_CFGPARAMETER_HANDLER(config_parameter_changed);
void config_parameter_changed(byte param, word * value)
{
Serial.print("config_parameter_changed");
}
Code: Select all
asm volatile (" jmp 0");
1)-2) Works ok. I do it on Z-Way with my Razberry.Riri wrote: ↑26 Jun 2018 17:00Hi,
Thank you very much for this beta version.
I installed this version with the bootloader too (you never know). I forced it with downgrade 2.1.1 then 2.1.4 (It can also be done by changing the security S2->S0->S2)
digitalRead, zunoSaveCFGParam and zunoLoadCFGParam works fine ! Thanks !
Here are other small problems that I discovered after writing to you and it worked with version 2.1.3 (I use the eedomus box):
1)
function config_parameter_changed the function is no longer called, the program never goes in.
Here is the block that is never executed :
2)Code: Select all
ZUNO_SETUP_CFGPARAMETER_HANDLER(config_parameter_changed); void config_parameter_changed(byte param, word * value) { Serial.print("config_parameter_changed"); }
When I write and read a configuration parameter from the box eedomus, I do not recover what I write (screenshot) :
I use COMMAND_CLASS_CONFIGURATION the CONFIGURATION_SET with for exemple the param 66
2018-06-26.png
I write 1*256 + 5 and i read only 256
it seems as if the last byte was not written
3)
On the pin 3,4,5,6,7,8 (analog and TX RX), used in PULLUP, digitalRead works quickly when it goes low but they take about a second to give value by going to the up state.
to counteract this, i write digitalWrite(pin,HIGH), just after the read for these pines, and it's work fine. Is there an other solution ?
Note it was the same case in 2.1.3. It's not specially for the version 2.1.4
4)
Is there a possibility to access the green service led, I used all the pins, even the 13.
5)
Also, is there a possibility to reboot from programme. I see this instruction but it not works:Thank you again for this precious help and this reactivityCode: Select all
asm volatile (" jmp 0");
Eric
Code: Select all
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
Z-Uno has an on-board LED you can control. It is attached to digital pin 13.
LED_BUILTIN is an internal Define which can be used to access this LED.
This example demonstrates the simple blink programm, where the blink interval can be changed from the Z-Wave controller.
More information on http://z-uno.z-wave.me/
You can cofigure duration using parameter #64.
*/
//initial period of the blink is 1 second
byte dimmerValue=100;
word coef;
byte changed = FALSE;
byte count = 0;
byte type = 0;
//Next line sets up Z-Uno channels. In this case it adds the Switch Multilevel channel
ZUNO_SETUP_CHANNELS(ZUNO_SWITCH_MULTILEVEL(getSwitchMultilevelValue,setSwitchMultilevelValue));
// We have to define handler for configuration parameters
ZUNO_SETUP_CFGPARAMETER_HANDLER(config_parameter_changed);
// the setup function runs once, when you press reset or power the board
void setup() {
// set digital pin 13 as an output.
pinMode(LED_BUILTIN, OUTPUT);
dimmerValue = 100;
// load value of the first user-defined configuration parameter to variable coef
// The first user defined parameter is #64, the second is #65 etc
// We can use up to 32 user-defined parameters
zunoLoadCFGParam(64,&coef);
Serial0.println(coef, HEX);
// In case we don't have right value here
if(coef > 20)
coef = 20;
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(dimmerValue*byte(coef)); // wait for timeout
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(dimmerValue*byte(coef)); // wait for timeout
}
void config_parameter_changed(byte param, word * value)
{
// Here we get the new vaue of our prameters
if(param == 64) // The first user-defined parameter
{
coef = *value;
}
Serial0.println("HANDLER!");
Serial0.println(coef, HEX);
}
//The setSwitchMultilevelValue runs only when a new value comes from the controller by Z-Wave
void setSwitchMultilevelValue(byte newValue) {
//save new value in a variable
dimmerValue = newValue;
}
//The setSwitchMultilevelValue runs only when the controller asks for the current blink rate by Z-Wave
byte getSwitchMultilevelValue(void) {
//return previously saved value
return dimmerValue;
}
Code: Select all
// Connect SCL to #9, SDA to #10
#include <Wire.h>
#include <ZUNO_MCP23017.h>
ZUNO_MCP23017 mcp;
void setup() {
mcp.begin(); // use default address
mcp.pinMode(0, OUTPUT);
}
void loop() {
delay(100);
mcp.digitalWrite(0, HIGH);
delay(100);
mcp.digitalWrite(0, LOW);
}
Code: Select all
void setup() {
Serial.begin(115200);
}
byte count = 0;
void loop() {
count++;
Serial.print("LOOP:");
Serial.println(count);
if(count>50){
Serial.print("Rebooting...");
zunoReboot();
}
delay(1000);
}
Code: Select all
ZUNO_SETUP_CHANNELS(ZUNO_SWITCH_MULTILEVEL(getSwitchMultilevelValue,setSwitchMultilevelValue));
ZUNO_SETUP_CFGPARAMETER_HANDLER(config_parameter_changed);
word w = 0;
void config_parameter_changed(byte param, word * value)
{
Serial.println("config_parameter_changed");
w = *value;
}
void setup()
{
Serial.begin();
}
void loop()
{
if (Serial.available() > 0) {
byte serialByte = Serial.read();
if ((serialByte=='C') || (serialByte=='c')) {
Serial.println(w, DEC);
}
}
}
//The setSwitchMultilevelValue runs only when a new value comes from the controller by Z-Wave
void setSwitchMultilevelValue(byte newValue) {
//save new value in a variable
w = (word)newValue;
}
//The setSwitchMultilevelValue runs only when the controller asks for the current blink rate by Z-Wave
byte getSwitchMultilevelValue(void) {
//return previously saved value
return (byte)w;
}
Code: Select all
ZUNO_SETUP_CFGPARAMETER_HANDLER(config_parameter_changed);
word w = 0;
void config_parameter_changed(byte param, word * value)
{
Serial.println("config_parameter_changed");
w = *value;
}
void setup()
{
ZUNO_START_CONFIG();
ZUNO_ADD_CHANNEL(ZUNO_SWITCH_MULTILEVEL_CHANNEL_NUMBER,0,0);
ZUNO_COMMIT_CONFIG();
Serial.begin();
}
void loop()
{
if (Serial.available() > 0) {
byte serialByte = Serial.read();
if ((serialByte=='C') || (serialByte=='c')) {
Serial.println(w, DEC);
}
}
}
void zunoCallback(void)
{
switch(callback_data.type) {
case ZUNO_CHANNEL1_GETTER:
callback_data.param.bParam = (byte)w;
break;
case ZUNO_CHANNEL1_SETTER:
w = (word)callback_data.param.bParam;
break;
default:
break;
}
}