B4R Question 7 segment led display

emvpic

Member
Licensed User
Longtime User
I have a 1.2" 7-segment led display. With the HT16K33 controller. I have made a clock with this display on Arduino, which connects to the internet and gets the time from the "pool.ntp.org" server.
B4X:
#include <WiFi.h>
#include "time.h"
#include "HT16K33.h"

HT16K33 seg(0x70);


const char* ssid       = "*****";
const char* password   = "*****";

const char* ntpServer = "pool.ntp.org";
const long  gmtOffset_sec = 3600;
const int   daylightOffset_sec = 3600;

void printLocalTime()
{
  struct tm timeinfo;
  if(!getLocalTime(&timeinfo)){
    Serial.println("Fallo en la obtencíon de la hora");
    return;
  }
  Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
  //Averiguar como transformar H y M para mostrarlo en displayTime
  char hora[3];
  strftime(hora,3, "%H",&timeinfo);
  char minuto[3];
  strftime(minuto,3, "%M",&timeinfo);
 
  Serial.println(hora);
  Serial.println(minuto);
  int ihora=String(hora).toInt();
  int iminuto=String(minuto).toInt();
 
  seg.displayTime(ihora,iminuto,true,true);
 // seg.displayTime(%H,%M,true,false);
}

void setup()

{
  Serial.begin(115200);
 
  seg.begin();
  //Wire.setClock(100000);
  seg.displayOn();
  seg.setDigits(4);


  //Conectar al wifi
  Serial.printf("Conectando %s ", ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
  }
  Serial.println(" Conectado");
 
  //Iniciar y obtener la hora
  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
  printLocalTime();

  //Desconectar el Wifi si no es necesario
  WiFi.disconnect(true);
  WiFi.mode(WIFI_OFF);
}

void loop()
{
  delay(1000);
  printLocalTime();
}

I want to do the same but using B4R, I have hardly seen examples and I am very lost. At the moment what I have in B4R connects to the server "time.nist.gov" to get the time. I don't know how I could use the Arduino libraries in B4R to show the time on the 7-segment display with the HT16K33 controller.
 
Top