var status var correction=0 var settings[10] var i call leds.top(10,32,12) #subroutine to display correctionion value one the top led ring sub ledsetting if correction>=0 then call leds.circle(0,correction,0,0,0,0,0,0) end if correction>31 then call leds.circle(0,31,correction-31,0,0,0,0,0) if correction>50 then #bound correction correction=50 end end if correction<0 then call leds.circle(0,0,0,0,0,0,0,-correction) end if correction<-31 then call leds.circle(0,0,0,0,0,0,(-correction-31),31) if correction<-50 then correction=-50 end end #write corretcion in settings #!!! attention writing in settings is not safe, if you don't know what you are doing!!! call _system.settings.write(8,256+correction) call _system.settings.write(9,256-correction) #user envent to read settings onevent readsettings for i in 0:9 do call _system.settings.read(i,settings[i]) end #managing buttuns onevent button.right if motor.left.target!=0 then if button.right==1 then correction+=1 end callsub ledsetting end onevent button.left if motor.left.target!=0 then if button.left==1 then correction-=1 end callsub ledsetting end onevent button.center if button.center==1 then call leds.top(32,0,0) motor.left.target=0 motor.right.target=0 call _system.settings.flash() else call leds.top(10,32,12) end onevent button.backward if button.backward==1 then motor.left.target-=STEPSPEED motor.right.target-=STEPSPEED if motor.left.target<=-3*STEPSPEED then motor.left.target=-3*STEPSPEED motor.right.target=-3*STEPSPEED end end onevent button.forward if button.forward==1 then motor.left.target+=STEPSPEED motor.right.target+=STEPSPEED if motor.left.target>=3*STEPSPEED then motor.left.target=3*STEPSPEED motor.right.target=3*STEPSPEED end end #events to make graph #onevent motor #emit speed [motor.left.speed,motor.right.speed] #user event to set users correctionions value #!!! Do not use if you don't know what you are doing!!!! onevent absolut call _system.settings.write(8,event.args[0]) call _system.settings.write(9,event.args[1])