/**
*/
#include "pico/stdlib.h"
int inverte10bits(int x)
{
int temp = 0;
temp = (x & 0x0001) ? temp | 0x0200 : temp;
temp = (x & 0x0002) ? temp | 0x0100 : temp;
temp = (x & 0x0004) ? temp | 0x0080 : temp;
temp = (x & 0x0008) ? temp | 0x0040 : temp;
temp = (x & 0x0010) ? temp | 0x0020 : temp;
temp = (x & 0x0020) ? temp | 0x0010 : temp;
temp = (x & 0x0040) ? temp | 0x0008 : temp;
temp = (x & 0x0080) ? temp | 0x0004 : temp;
temp = (x & 0x0100) ? temp | 0x0002 : temp;
temp = (x & 0x0200) ? temp | 0x0001 : temp;
return temp;
}
void setup()
{
int chave; // 1 2345678911234567891
gpio_init_mask(0b1100011111111111111111110000);
gpio_set_dir_out_masked(0b0000000000000011111111110000);
gpio_set_dir_in_masked (0b1100011111111100000000000000);
for(int i = 14;i<23;i++){
gpio_pull_up(i);
}
gpio_pull_up(26);
gpio_pull_up(27);
//loop
while(true){
int x = ~gpio_get_all();
x= (x>>14);
if (x & 0x2000)
{
gpio_put_masked(0b11111111110000,0x3FF<<4);
sleep_ms(300);
gpio_put_masked(0b11111111110000,0x000);
}
else
{
x= (x & 0x1000) ? x | 0x0200 : x & (~0x0200);
x= x & 0x03FF;
x = inverte10bits(x);
gpio_put_masked(0b11111111110000,x<<4);
}
sleep_ms(300);
}
}
void loop() {}