Berry add `energy.update_total()` to call `EnergyUpdateTotal()` from energy driver (#19117)

This commit is contained in:
s-hadinger 2023-07-15 17:06:10 +02:00 committed by GitHub
parent ebca2f0a07
commit ada754c582
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
- Partition Wizard is now able to convert to safeboot from Shelly partition layout (#19034)
- Matter mini-profiler (#19075)
- Berry `_class` can be used in `static var` initialization code (#19088)
- Berry add `energy.update_total()` to call `EnergyUpdateTotal()` from energy driver
### Breaking Changed

View File

@ -10,6 +10,7 @@
#ifdef USE_ENERGY_SENSOR
extern struct ENERGY Energy;
extern int energy_update_total(bvm *vm);
#include "solidify/solidified_energy.h"
#include "be_fixed_energy.h"
@ -24,6 +25,8 @@ module energy (scope: global) {
read, closure(energy_read_closure)
member, closure(energy_member_closure)
setmember, closure(energy_setmember_closure)
update_total, func(energy_update_total)
}
@const_object_info_end */

View File

@ -31,6 +31,15 @@
*
\*********************************************************************************************/
extern "C" {
int32_t energy_update_total(struct bvm *vm);
int32_t energy_update_total(struct bvm *vm) {
EnergyUpdateTotal();
be_return_nil(vm);
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof" // avoid warnings since we're using offsetof() in a risky way