HelTecAutomation / Heltec_ESP8266

Arduino library for Heltec ESP8266 based boards
Other
54 stars 18 forks source link

heltec.h issue in Arduino IDE #1

Closed jrbski closed 5 years ago

jrbski commented 5 years ago

When I try to compile the factory test for Wifikit 8, I get the error 'class Heltec_ESP8266' has no member named 'display'

Heltec-Aaron-Lee commented 5 years ago

please install the newest Heltec ESP8266 development framework: https://docs.heltec.cn/#/en/user_manual/how_to_install_esp8266_Arduino

semaf commented 5 years ago

Does not work anyway!

The example is HelloWorld which will be installed over the Library Manager

// This example just provide basic function test;
// For more informations, please vist www.heltec.cn or mail to support@heltec.cn

#include <Wire.h>  // Only needed for Arduino 1.6.5 and earlier
#include "heltec.h" // alias for `#include "SSD1306Wire.h"`

void setup() {
  Heltec.begin(true /*DisplayEnable Enable*/, true /*Serial Enable*/);
  Heltec.display->init();
  Heltec.display->flipScreenVertically();
  Heltec.display->setFont(ArialMT_Plain_10);

  Heltec.display->drawString(0,0,"Hello World!");
  Heltec.display->display();
}

void loop() { }

Trying to compile

HelloWorld:11:10: error: 'class Heltec_ESP8266' has no member named 'display'
   Heltec.display->init();
          ^
HelloWorld:12:10: error: 'class Heltec_ESP8266' has no member named 'display'
   Heltec.display->flipScreenVertically();
          ^
HelloWorld:13:10: error: 'class Heltec_ESP8266' has no member named 'display'
   Heltec.display->setFont(ArialMT_Plain_10);
          ^
HelloWorld:13:27: error: 'ArialMT_Plain_10' was not declared in this scope
   Heltec.display->setFont(ArialMT_Plain_10);
                           ^
HelloWorld:15:10: error: 'class Heltec_ESP8266' has no member named 'display'
   Heltec.display->drawString(0,0,"Hello World!");
          ^
HelloWorld:16:10: error: 'class Heltec_ESP8266' has no member named 'display'
   Heltec.display->display();
          ^
exit status 1
'class Heltec_ESP8266' has no member named 'display'

The heltec.h files content:

#ifndef _HELTEC_H_
#define _HELTEC_H_

#if defined(ESP8266)

#include <Arduino.h>
#include <Wire.h>

#if defined( WIFI_Kit_8 )
#include "oled/SSD1306.h"
#include "oled/OLEDDisplayUi.h"

#endif

class Heltec_ESP8266 {

 public:
    Heltec_ESP8266();
    ~Heltec_ESP8266();

    void begin(bool DisplayEnable=true, bool SerialEnable=true);
//#if defined( WIFI_LoRa_32 ) || defined( WIFI_LoRa_32_V2 ) || defined( Wireless_Stick )
//   LoRaClass LoRa;
//#endif

    SSD1306Wire *display;

/*wifi kit 32 and WiFi LoRa 32(V1) do not have vext*/
//    void VextON(void);
//    void VextOFF(void);
};

extern Heltec_ESP8266 Heltec;

#else
#error ��This library only supports boards with ESP8266 processor.��
#endif

#endif

The heltec.cpp

// Copyright (c) Heltec Automation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include "heltec.h"

Heltec_ESP8266::Heltec_ESP8266(){

#if defined( WIFI_Kit_8 )
     display = new SSD1306Wire(0x3c, SDA, SCL, OLED_RST, GEOMETRY_128_32);
//#elif defined( Wireless_Stick )
//    display = new SSD1306Wire(0x3c, SDA_OLED, SCL_OLED, RST_OLED, GEOMETRY_64_32);
#endif
}

Heltec_ESP8266::~Heltec_ESP8266(){
    delete display;
}

void Heltec_ESP8266::begin(bool DisplayEnable, bool SerialEnable) {

//#if defined( WIFI_LoRa_32_V2 ) || defined( Wireless_Stick )

//  VextON();
//#endif

    // UART
    if (SerialEnable) {
        Serial.begin(115200);
        Serial.flush();
        delay(50);
        Serial.print("Serial initial done\r\n");
    }

    // OLED
    if (DisplayEnable){
        display->init();
        display->flipScreenVertically();
        display->setFont(ArialMT_Plain_10);
        display->drawString(0, 0, "OLED initial done!");
        display->display();

        if (SerialEnable){
            Serial.print("you can see OLED printed OLED initial done!\r\n");
        }
    }

    // LoRa INIT
//  if (LoRaEnable)
//  {
//#if defined(WIFI_Kit_32)
//      if(SerialEnable && WIFI_Kit_32){
//          Serial.print("The WiFi Kit 32 not have LoRa function, LoRa option must be FALSE!!!\r\n");
//      }
//#endif
//
//
//#if defined( WIFI_LoRa_32 ) || defined( WIFI_LoRa_32_V2 ) || defined( Wireless_Stick )
//      //LoRaClass LoRa;
//
//      SPI.begin(SCK,MISO,MOSI,SS);
//      LoRa.setPins(SS,RST_LoRa,DIO0);
//      if (!LoRa.begin(BAND,PABOOST))
//      {
//          if (SerialEnable){
//              Serial.print("Starting LoRa failed!\r\n");
//          }
//          if(DisplayEnable){
//              display->clear();
//              display->drawString(0, 0, "Starting LoRa failed!");
//              display->display();
//              delay(300);
//          }
//          while (1);
//      }
//      if (SerialEnable){
//          Serial.print("LoRa Initial success!\r\n");
//      }
//      if(DisplayEnable){
//          display->clear();
//          display->drawString(0, 0, "LoRa Initial success!");
//          display->display();
//          delay(300);
//      }
//#endif
//  }
}

//void Heltec_ESP32::VextON(void)
//{
//  pinMode(Vext,OUTPUT);
//  digitalWrite(Vext, LOW);
//}
//
//void Heltec_ESP32::VextOFF(void) //Vext default OFF
//{
//  pinMode(Vext,OUTPUT);
//  digitalWrite(Vext, HIGH);
//}

Heltec_ESP8266 Heltec;

If somebody can see the member display, please let me know.

Heltec-Aaron-Lee commented 5 years ago

@semaf image I think your problem is caused by your ESP8266 framework problems. Check carefully and follow the user manual step by step.

Anyway, resources on this page may help you: https://heltec.org/project/wifi-kit-8/

samaphp commented 4 years ago

Same here. I'm having the same error of @semaf

error: 'class Heltec_ESP8266' has no member named 'display'
   Heltec.display->init();

I realized that I have to follow this guide for Mac: https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/InstallGuide/mac.md

Or from here for any other OS: https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series

Then you may need to choose the port USBtoUART.

You may want to follow the install via Github: https://heltec.org/wifi_kit_install/

And pay attention to this note: *Arduino library must in ” :\Documents\Arduino\libraries\ ” path.**

Good luck!