'Heltec display not working when uploaded from Arduino-CLI

I was trying to upload some display code into a Heltec WiFi Kit 32 using Arduino-CLI. Although the outputs work with the pins, it just refuses to turn the on-board display on. I tried uploading from the standard Arduino application, and that one worked. I know I can just use the Arduino application, but was wondering why it wouldn't work with Arduino-CLI. The code I was using is the given factory test example code downloaded with the Heltec WiFi Kit 32 library. There aren't any compilation errors or problems uploading to the board.

Edit: Since someone wanted the commands I used, it's ardiuno-cli compile --fqbn esp32:esp32:heltec_wifi_kit_32 Testing and arduino-cli upload -p /dev/ttyS5 --fqbn esp32:esp32:heltec_wifi_kit_32 Testing. It's just the standard compile and upload commands. The code from the example is below.

/*
 * HelTec Automation(TM) WIFI_Kit_32 factory test code, witch includ
 * follow functions:
 *
 * - Basic OLED function test;
 *
 * - Basic serial port test(in baud rate 115200);
 *
 * - LED blink test;
 *
 * - WIFI join and scan test;
 *
 * - Timer test and some other Arduino basic functions.
 *
 * by Aaron.Lee from HelTec AutoMation, ChengDu, China
 * 成都惠利特自动化科技有限公司
 * www.heltec.cn
 *
 * this project also realess in GitHub:
 * https://github.com/HelTecAutomation/Heltec_ESP32
*/

#include "heltec.h"
#include "WiFi.h"
#include "images.h"


void logo(){
    Heltec.display -> clear();
    Heltec.display -> drawXbm(0,5,logo_width,logo_height,(const unsigned char *)logo_bits);
    Heltec.display -> display();
}

void WIFISetUp(void)
{
    // Set WiFi to station mode and disconnect from an AP if it was previously connected
    WiFi.disconnect(true);
    delay(1000);
    WiFi.mode(WIFI_STA);
    WiFi.setAutoConnect(true);
    WiFi.begin("Your WIFI SSID","Your WIFI Password");
    delay(100);

    byte count = 0;
    while(WiFi.status() != WL_CONNECTED && count < 10)
    {
        count ++;
        delay(500);
        Heltec.display -> drawString(0, 0, "Connecting...");
        Heltec.display -> display();
    }

    Heltec.display -> clear();
    if(WiFi.status() == WL_CONNECTED)
    {
        Heltec.display -> drawString(0, 0, "Connecting...OK.");
        Heltec.display -> display();
//      delay(500);
    }
    else
    {
        Heltec.display -> clear();
        Heltec.display -> drawString(0, 0, "Connecting...Failed");
        Heltec.display -> display();
//      while(1);
    }
    Heltec.display -> drawString(0, 10, "WIFI Setup done");
    Heltec.display -> display();
    delay(500);
}

void WIFIScan(void)
{
    Heltec.display -> drawString(0, 20, "Scan start...");
    Heltec.display -> display();

    int n = WiFi.scanNetworks();
    Heltec.display -> drawString(0, 30, "Scan done");
    Heltec.display -> display();
    delay(500);
    Heltec.display -> clear();

    if (n == 0)
    {
        Heltec.display -> clear();
        Heltec.display -> drawString(0, 0, "no network found");
        Heltec.display -> display();
        while(1);
    }
    else
    {
    Serial.print(n);
        Heltec.display -> drawString(0, 0, (String)n);
        Heltec.display -> drawString(14, 0, "networks found:");
        Heltec.display -> display();
        delay(500);

        for (int i = 0; i < n; ++i) {
        // Print SSID and RSSI for each network found
            Heltec.display -> drawString(0, (i+1)*9,(String)(i + 1));
            Heltec.display -> drawString(6, (i+1)*9, ":");
            Heltec.display -> drawString(12,(i+1)*9, (String)(WiFi.SSID(i)));
            Heltec.display -> drawString(90,(i+1)*9, " (");
            Heltec.display -> drawString(98,(i+1)*9, (String)(WiFi.RSSI(i)));
            Heltec.display -> drawString(114,(i+1)*9, ")");
            //            display.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
            delay(10);
        }
    }

    Heltec.display -> display();
    delay(800);
    Heltec.display -> clear();

}

void setup()
{
    pinMode(LED,OUTPUT);

    Heltec.begin(true /*DisplayEnable Enable*/, false /*LoRa Enable*/, true /*Serial Enable*/);

    logo();
    delay(300);
    Heltec.display->clear();
    WIFISetUp();
  
  WiFi.disconnect(true);//重新初始化WIFI
  delay(1000);
  WiFi.mode(WIFI_STA);
  WiFi.setAutoConnect(true);
}

void loop()
{
  digitalWrite(LED,LOW);
    WIFIScan();
    delay(2500);
  digitalWrite(LED, HIGH);
  delay(2500);
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source