1 (edited by uuu000 2021-12-16 19:36:07)

Topic: Помогите начинающему

Друзья,помогите новичку.
Не могу понять как разместить скачанный после создания интерфейса скетч в тело моей программы (включение и выключение светодиода
кнопкой)  Имею начальные навыки программирования AVR в СИ, но здесь ничего не могу сделать

#define LED 5 // D1(gpio5)
#define BUTTON 4 //D2(gpio4)
//Let's say you have your push button on pin 4
int switchState = 0; // actual read value from pin4
int oldSwitchState = 0; // last read value from pin4
int lightsOn = 0; // is the switch on = 1 or off = 0

void setup() { 
 pinMode(BUTTON, INPUT); // push button 
 pinMode(LED, OUTPUT); // anything you want to control using a switch e.g. a Led
}
void loop() {
 switchState = digitalRead(BUTTON); // read the pushButton State
 if (switchState != oldSwitchState) // catch change
 {
 oldSwitchState = switchState;
 if (switchState == HIGH)
 {
 // toggle
 lightsOn = !lightsOn;
 }
 }
 if(lightsOn)
 {
 digitalWrite(LED, HIGH); // set the LED on
 } else {
 digitalWrite(LED, LOW); // set the LED off
 }
 }

Скачанный скетч

/*
   -- New project --
   
   This source code of graphical user interface 
   has been generated automatically by RemoteXY editor.
   To compile this code using RemoteXY library 3.1.6 or later version 
   download by link http://remotexy.com/en/library/
   To connect using RemoteXY mobile app by link http://remotexy.com/en/download/                   
     - for ANDROID 4.8.01 or later version;
     - for iOS 1.5.1 or later version;
    
   This source code is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.    
*/

//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// определение режима соединения и подключение библиотеки RemoteXY 
#define REMOTEXY_MODE__ESP8266WIFI_LIB
#include <ESP8266WiFi.h>

#include <RemoteXY.h>

// настройки соединения 
#define REMOTEXY_WIFI_SSID "HOTBOX 4-7EA8"
#define REMOTEXY_WIFI_PASSWORD "0507769926"
#define REMOTEXY_SERVER_PORT 6377


// конфигурация интерфейса  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,1,0,23,0,13,13,1,
  70,32,43,7,9,9,26,37,135,0,
  1,0,19,6,12,12,2,31,88,0 };
  
// структура определяет все переменные и события вашего интерфейса управления 
struct {

    // input variables
  uint8_t button_1; // =1 если кнопка нажата, иначе =0 

    // output variables
  uint8_t led_1; // led state 0 .. 2 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

#define PIN_BUTTON_1 D2


void setup() 
{
  RemoteXY_Init (); 
  
  pinMode (PIN_BUTTON_1, OUTPUT);
  
  // TODO you setup code
  
}

void loop() 
{ 
  RemoteXY_Handler ();
  
  digitalWrite(PIN_BUTTON_1, (RemoteXY.button_1==0)?LOW:HIGH);
  
  // TODO you loop code
  // используйте структуру RemoteXY для передачи данных
  // не используйте функцию delay() 


}

Попробовал совместить

/* -- New project --
   
   This source code of graphical user interface 
   has been generated automatically by RemoteXY editor.
   To compile this code using RemoteXY library 3.1.6 or later version 
   download by link http://remotexy.com/en/library/
   To connect using RemoteXY mobile app by link http://remotexy.com/en/download/                   
     - for ANDROID 4.8.01 or later version;
     - for iOS 1.5.1 or later version;
    
   This source code is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.    
*/

//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// определение режима соединения и подключение библиотеки RemoteXY 
#define REMOTEXY_MODE__ESP8266WIFI_LIB
#include <ESP8266WiFi.h>

#include <RemoteXY.h>

// настройки соединения 
#define REMOTEXY_WIFI_SSID "HOTBOX 4-7EA8"
#define REMOTEXY_WIFI_PASSWORD "0507769926"
#define REMOTEXY_SERVER_PORT 6377


// конфигурация интерфейса  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,1,0,23,0,13,13,1,
  70,32,43,7,9,9,26,37,135,0,
  1,0,19,6,12,12,2,31,88,0 };
  
// структура определяет все переменные и события вашего интерфейса управления 
struct {

    // input variables
  uint8_t button_0; // =1 если кнопка нажата, иначе =0 

    // output variables
  uint8_t led_1; // led state 0 .. 2 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

#define PIN_BUTTON_1 D2


#define LED 5 // D1(gpio5)
#define BUTTON 4 //D2(gpio4)
//Let's say you have your push button on pin 4
int switchState = 0; // actual read value from pin4
int oldSwitchState = 0; // last read value from pin4
int lightsOn = 0; // is the switch on = 1 or off = 0

void setup() { 
 RemoteXY_Init (); 
 pinMode(BUTTON, INPUT); // push button 
 pinMode(LED, OUTPUT); // anything you want to control using a switch e.g. a Led
}
void loop() {

  RemoteXY_Handler ();
   digitalWrite(PIN_BUTTON_1, (RemoteXY.button_1==0)?LOW:HIGH);
 switchState = digitalRead(BUTTON); // read the pushButton State
 if (switchState != oldSwitchState) // catch change
 {
 oldSwitchState = switchState;
 if (switchState == HIGH)
 {
 // toggle
 lightsOn = !lightsOn;
 }
 }
 if(lightsOn)
 {
 digitalWrite(LED, LOW); // set the LED on
 } else {
 digitalWrite(LED, HIGH); // set the LED off
 }
 }

и получил такую ошибку
'struct<unnamed>' has no member named 'button_1'; did you mean 'button_0'?
Где искать эту ошибку?

Спасибо.

2 (edited by Gunner 2021-12-16 19:47:56)

Re: Помогите начинающему

In your RemoteXY editor code you have...

    // input variables
  uint8_t button_1; // =1 если кнопка нажата, иначе =0 

And button_1 is the reference used in the rest of the code.

But in your "combined" code you have it as this...

    // input variables
  uint8_t button_0; // =1 если кнопка нажата, иначе =0 
"And voila, which is French for.......'and then I found out.'" - Ready Player One

3

Re: Помогите начинающему

Спасибо.
Исправил, прошивается, соединяется ,но не работает.?