Bascomowców

Jul 19, 2012 0 Replies

formatting link
Za Basicem nie przepadam. Specjalnie dla Tibbo trochę musiałem grzebnąć w tym języku. Za to Bascomowcom przesiadkę na 32 bity pewnie ułatwi, szczególnie że już wspiera popularne i tanie u nas układy STM32. Przykład chyba dobrze wygląda, a zapis typu @nazwa nie odstraszy aż tak bardzo...



' Project name: ' Button_Test (Sample usage of Button() function) [...]



program Button_Test dim oldstate as byte main: GPIO_Digital_Input(@GPIOA_BASE, _GPIO_PINMASK_0) ' Set PA0 as digital input GPIO_Digital_Output(@GPIOD_BASE, _GPIO_PINMASK_ALL) ' Set PORTD as digital output oldstate = 0



while TRUE if (Button(GPIOA_IDR, 0, 1, 1) <> 0) then ' detect logical one on PA0 pin oldstate = 1 ' update flag end if if (oldstate and Button(GPIOA_IDR, 0, 1, 0)) then ' detect one-to-zero transition on PA0 pin GPIOD_ODR = not GPIOD_ODR ' invert PORTD value oldstate = 0 ' update flag end if wend ' endless loop end.


Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required