mb944
1
Hello midiboxers!
I am really getting envolved in midiboxing and having enjoyed all the physical hardware developement side of it,
I’m having some fun with Coding.
What I am triying to do here is to Light a red led when an encoder approaches its maximum absolute value (above 100).
I am using enc_example2_v1_3Â as a skelletton for my little project.
I noticed that Just before sending the encoder value (third midi byte), MIOS moves it from TMP1 to W
I assumed I could insert my code here and compare W with the WARNING_LEVEL…
Here’s what I’m wrote:
;; send the third MIDI byte
movf TMP1, W ; value from 0x00 to 0x7f
movlw 0x64 ; ABOVE THIS VALUE,LIGHT WARNING LED
movwf WARNING_LEVEL
movf TMP1, W ; value from 0x00 to 0x7f
CPFSGT WARNING_LEVEL; COMPARE ENCODER VALUE WITH WARNING_LEVEL
movlw 0x14
CALL MIOS_DOUT_PinSet1; LIGHT WARNING LED
Call MIOS_MIDI_TxBufferPut
At the moment, PINSET1 is being called every time I move the encoder.
Can I make CPFSGT skip two lines? Better still, can I use something like:
IF w>100 then
movlw 0x14
CALL MIOS_DOUT_PinSet1
end if
Thanks for any suggestions!
Best regards,
Alex
TL1
2
CPFSGT WARNING_LEVEL; COMPARE ENCODER VALUE WITH WARNING_LEVEL
goto No_Warning
movlw 0x14
CALL MIOS_DOUT_PinSet1; LIGHT WARNING LED
No_Warning
Call MIOS_MIDI_TxBufferPut
I think this works…
The ‘skip’ instructions only skip the next instruction, so you were only skipping “movlw  0x14” 
You could probably also do something like:
CPFSGT WARNING_LEVEL; COMPARE ENCODER VALUE WITH WARNING_LEVEL
CALL USER_WARNING_LED; LIGHT WARNING LED SUBROUTINE
CALL MIOS_MIDI_TxBufferPut
And have
;; --------------------------------------------------------------------------
;;Â FUNCTION: USER_WARNING_LED
;;Â DESCRIPTION: Lights the warning LED
;;Â IN: -
;;Â OUT:Â -
;;Â USES: W
;;
;; --------------------------------------------------------------------------
USER_WARNING_LED
   movlw  USER_WARNING_LED0_PIN ; Set Warning LED Pin Value
   CALL MIOS_DOUT_PinSet1; LIGHT WARNING LED
   RETURN
Included elsewhere. Don;t forget to define USER_WARNING_LED0_PIN somewhere too.
Makes it usable in other areas of code, more modular, etc…
Of course if you want more than one warning LED it may be better to pass the values of the pins prior to calling subroutine, like you did it…
It’s 4:30am and I am very very tired, I hope I haven’t missed something here heheheh 