Skip to content

Commit

Permalink
HerePro: add enable parameter for LED
Browse files Browse the repository at this point in the history
  • Loading branch information
bugobliterator committed May 21, 2024
1 parent 0a204b2 commit d1a444a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions HerePro/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ define AP_PERIPH_HAVE_LED TRUE

define AP_SCRIPTING_ENABLED 1
define SCRIPTING_HEAP_SIZE (64*1024)
define AP_PARAM_DYNAMIC_ENABLED 1

define GPS_MOVING_BASELINE 1

Expand Down
15 changes: 15 additions & 0 deletions HerePro/scripts/hereproled.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ local animation_end = 0
local current_anim = 0
local brightness = 0

-- the table key must be used by only one script on a particular flight
-- controller. If you want to re-use it then you need to wipe your old parameters
-- the key must be a number between 0 and 200. The key is persistent in storage
local PARAM_TABLE_KEY = 72
local PARAM_TABLE_PREFIX = "ANIM_"
assert(param:add_table(PARAM_TABLE_KEY, PARAM_TABLE_PREFIX, 1), 'could not ANIM_ add param table')

function bind_add_param(name, idx, default_value)
assert(param:add_param(PARAM_TABLE_KEY, idx, name, default_value), string.format('could not add param %s', name))
return Parameter(PARAM_TABLE_PREFIX .. name)
end
local enable = bind_add_param('ENABLE', 1, 1)
-- constrain a value between limits
function constrain(v, vmin, vmax)
if v < vmin then
Expand Down Expand Up @@ -308,6 +320,9 @@ function animation_state_machine(vehicle_state)
end

function update() -- this is the loop which periodically runs
if enable:get() == 0 then
return update, 1000
end
local next_call = 20
local vehicle_state = periph:get_vehicle_state()
animation_state_machine(vehicle_state)
Expand Down

0 comments on commit d1a444a

Please sign in to comment.