minimizing a soft

Bloody-orc

Senior Member
Hi. i'm trying to make a RF joystick but an running out of memory on picaxe 18. it reads 2 ADCs and acording to theyr position sends out one byte with serout command "serout 0, T2400, ($AA), byte". is there any way i could make it a bit smaller so i could also read 2 push buttons and send some more data.

<code><pre><font size=2 face='Courier'>
symbol keskel = 10
symbol edasi = 20
symbol tagasi = 30
symbol paremale = 40
symbol vasakule = 50
symbol sujuvvasakule = 60
symbol sujuvparemale = 70
symbol sujuvvasakuletagasi = 80
symbol sujuvparemaletagasi = 90

symbol EOM = 102
symbol SOM = 140

symbol cntr = 128
symbol cntrmin = 116
symbol cntrmax = 149
symbol left = 150
symbol right = 120
symbol fwd = 135
symbol back = 108

symbol x = b0 'edasitagasi
symbol y = b1 'k&#245;rvale
symbol suund = b2

main:
readadc 1, x
readadc 0, y


if x &gt; fwd and y &gt; cntrmin and y &lt;= cntrmax then _edasi
if x &lt; back and y &gt; cntrmin and y &lt; cntrmax then _tagasi
if x &gt; cntrmin and x &lt; cntrmax and y &lt; right then _paremale
if x &gt; cntrmin and x &lt; cntrmax and y &gt; left then _vasakule

if x &gt; fwd and y &gt; left then _sujuvvasakule
if x &gt; fwd and y &lt; right then _sujuvparemale
'if x &lt; back and y &gt; left then _sujuvvasakuletagasi
'if x &lt; back and y &lt; right then _sujuvparemaletagasi

_keskel:
suund = keskel
goto _send

_edasi:
suund = edasi
goto _send

_tagasi:
suund = tagasi
goto _send

_vasakule:
suund = vasakule
goto _send

_paremale:
suund = paremale
goto _send

_sujuvvasakule:
suund = sujuvvasakule
goto _send

_sujuvparemale:
suund = sujuvparemale
goto _send

'_sujuvvasakuletagasi:
'suund = sujuvvasakuletagasi
'goto _send

'_sujuvparemaletagasi:
'suund = sujuvparemaletagasi
'goto _send

_send:

serout 0, T2400, (SOM,suund)
goto main

</font></pre></code>
 

bgrabowski

Senior Member
Transmit 3 bytes, the two adc readings plus a byte containing the two switch states and then do the processing in the receiver software.
 

hippy

Ex-Staff (retired)
Two tricks ... Divide all the constants you put into 'suund' by ten and multiply up again in the reciever; that should save ~8 bytes. Put the code after the READADC and before &quot;_send:&quot; in a subroutine and replace all 'GOTO _send' with RETURN; that should save ~12 bytes, ~20 in total, ~15% saved.
 
Top