What do you want to achieve?
Hello, love what I’ve used so far of Squareline. I’m having an issue where I’m trying to store objects as a getter-accessed parameter of a class of custom objects in an array in a state.h/state.cpp file so that I can access them programatically. Doing this is causing my hardware (an m5stack core2) to crash on boot constantly. I’ve appended the relevant code below: Any help would be greatly appreciated!
What have you tried so far?
beacon.h
class beacon {
public:
beacon(double lat, double lng, lv_obj_t * arc, lv_obj_t * lock, lv_obj_t * lockOpen, lv_obj_t * status, lv_obj_t * distance);
lv_obj_t * ui(String el); // Returns a LVGL ui element
private:
lv_obj_t * _ui_arc;
lv_obj_t * _ui_lock;
lv_obj_t * _ui_lockOpen;
lv_obj_t * _ui_status;
lv_obj_t * _ui_distance;
double _lat;
double _lng;
bool _isInRange;
byte _unlockPercent;
};
beacon.cpp
beacon::beacon(double lat, double lng, lv_obj_t * arc, lv_obj_t * lock, lv_obj_t * lockOpen, lv_obj_t * status, lv_obj_t * distance) {
_lat = lat;
_lng = lng;
_isInRange = false;
_unlockPercent=0;
_unlockedAt = 0;
_ui_arc=arc;
_ui_lock=lock;
_ui_lockOpen=lockOpen;
_ui_status=status;
_ui_distance=distance;
};
lv_obj_t * beacon::ui(String el) {
return _ui_arc; // will break this down when working
}
state.h
extern beacon beacons[3];
state.cpp
static beacon beacon1(-33.91, 151.10,ui_beaconArc1,ui_beaconLock1,ui_beaconLockOpen1,ui_beaconStatus1,ui_beaconDistance1);
static beacon beacon2(-33.91, 151.10,ui_beaconArc2,ui_beaconLock2,ui_beaconLockOpen2,ui_beaconStatus2,ui_beaconDistance2);
static beacon beacon3(-33.91, 151.10,ui_beaconArc3,ui_beaconLock3,ui_beaconLockOpen3,ui_beaconStatus3,ui_beaconDistance3
);
beacon beacons[]={beacon1,beacon2,beacon3};
main.cpp
void ui_reset() {
for (beacon b : beacons) {
if (not true) {
lv_arc_set_value(beacons[0].ui("arc"),0); // this causes the crash
} else {
lv_arc_set_value(ui_beaconArc1,50); // this doesn't
}
// lv_label_set_text_fmt(b.ui_distance, "???");
}
void setup() {
...
lv_init(); // initialise LVGL
lv_disp_draw_buf_init(&draw_buf,b1,b2,(screenWidth*screenHeight)/10);
init_display();
init_touch();
ui_init(); // initialise the Squareline design
ui_reset();
Others
- SquareLine Studio version: latest running LVGL 8.2
- Operating system: PC (VSC/platformio)
- Target hardware: M5Stack Core2