BQ34Z100 icon indicating copy to clipboard operation
BQ34Z100 copied to clipboard

program down when define the global class.

Open wangnengjier opened this issue 11 months ago • 3 comments

i have a question。 first, the program is down when i define a global class. or when i use begin function. the code is following:

the mcu is stm32f103c8t8, the board support has been installed.

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

#ifdef U8X8_HAVE_HW_SPI #include <SPI.h> #endif #ifdef U8X8_HAVE_HW_I2C #include <Wire.h> #endif

U8G2_ST7567_JLX12864_F_4W_HW_SPI u8g2(U8G2_R2, /* cs=7*/ 4, /* dc=9*/ 3, /* reset=8*/ 2);
//bq34z100 myBattery; //if define the class here. the program will down.

uint8_t temp; uint8_t capacity; uint8_t voltage;

void setup() { // put your setup code here, to run once: u8g2.begin();
u8g2.enableUTF8Print(); u8g2.setContrast(80);

// myBattery.setup(0x101,3,8000,3369,1000); // myBattery.begin(); }

void loop() { // put your main code here, to run repeatedly: bq34z100 myBattery; u8g2.setFont(u8g2_font_unifont_t_chinese2); u8g2.clearBuffer(); u8g2.setCursor(0, 15); u8g2.print("this is a test "); u8g2.sendBuffer(); delay(2000);

//myBattery.begin(); //if enable this function. the program is also down. temp = myBattery.getTemp(); capacity = myBattery.getCapacity(); voltage = myBattery.getVoltage();

u8g2.clearBuffer();

u8g2.setCursor(0, 15); u8g2.print("temp:"); u8g2.print(temp);

u8g2.setCursor(0, 35); u8g2.print("capacity:");

u8g2.print(capacity);

u8g2.setCursor(0, 55); u8g2.print("voltage:");

u8g2.print(voltage); u8g2.sendBuffer(); delay(1000); }

wangnengjier avatar Feb 25 '24 09:02 wangnengjier

Hi, I do not know what you mean by "program down". This library has not been tested in over 3 years. I'll likely archive it if its broken now as I no longer have hardware to test Please try first with the included example.

Ralim avatar Feb 25 '24 10:02 Ralim

thanks for your reply.

once i remove the "//" mark of 12th line (//bq34z100 myBattery;) , the MCU don't work.
that means once i define a variant of bq34z100 class, the MCU don't work.

wangnengjier avatar Mar 12 '24 13:03 wangnengjier

and another question. i try to read the source code of bq34z100.cpp file. i find you define the public function( begin(), and writeConfig(); in head file, but no code is found in cpp file. is that right? ??

wangnengjier avatar Mar 12 '24 13:03 wangnengjier