mip-emit
works like the standard word emit
. It blocks the calling thread, as long as the character is not written to the MIP display. Horizontal (x) position is in pixel (0 to 167/399), vertical position (y) is in lines (0 to 17/29), a line consists of 8 pixels. Larger fonts takes more than one line.
mip-emit ( Char -- ) Emits a character (writes a character to the MIP display) mip-emit? ( -- Flag ) MIP ready to get a character (SPI not busy) hook-emit ( -- a-addr ) Hooks for redirecting terminal IO on the fly hook-emit? ( -- a-addr ) mippos! ( x y -- ) Set MIP cursor position, x horizontal position, for 6x8 font max. (168 / 6) -1, depends on the font's x size y vertical position (a line consists of 8 pixels), max. 17 for 168x144 or 29 for 400x240 displays. mippos@ ( -- x y ) Get the current MIP cursor position mipclr ( -- ) Clears the OLED display, sets the cursor to 0, 0 mipfont ( u -- ) Select the font, u: 0 6x8, 1 8x8, 2 8X16 , 3 12X16 >mip ( -- addr1 addr2 ) redirect to MIP >term ( addr1 addr2 -- ) terminate redirection
: mip-hallo ( -- ) hook-emit @ \ save emit hook ['] mip-emit hook-emit ! \ redirect terminal to mip-emit ." Hallo Velo! " cr ." ciao" hook-emit ! \ restore old hook ;or even simpler
: mip-hallo ( -- ) >mip \ redirect terminal to mip-emit ." Hallo Velo! " cr ." ciao" >term \ terminate redirection ;or on a command line
>mip .( Hallo Velo!) >termshow date and time on MIP (see CmsisRtos#How_to_use_Tasks for a background task).
: clock ( -- ) mipclr 3 mipfont -1 -1 -1 alarm! \ set an alarm every second begin wait-alarm \ wait a second 0 0 mippos! >mip .time >term key? until key drop ;