To display images on an Oled 128x64 I made 128x64 pixels BMP images with Photoshop. The BMP file has to be converted into a hex file, readable by the microcontroller. Every pixel is a bit. The first byte of 8-bits represents the first 8 pixels in the first column, second byte are the 8 pixels in the second column. There are 16 bytes for each column and 64 bytes for each row. A c# program converts the BMP to Hex. I added a tiny boost converter to raise the voltage from 1.5v to 5v, so it can run on a AAA battery.
source code for lalinea
This website shows how to use seeeduino xiao with Adafruit_TinyUSb library to emulate keyboard strokes.
When seeeduino is inserted into USB port it will run the code.
The code starts "cmd" from Windows+R run box and connects to sever using FTP and uploads files, then it starts putty, connects to the server and logs in.
I put a digitalRead on pin 4 just to have a part of the code run. Pin 4 is connect to a push button to ground (not shown in the picture).
pinMode(4, INPUT_PULLUP) seems to work.
Initially I got this error when uploading the code: Adafruit_USBD_HID does not name a type; did you mean Adafruit_USBD_CDC?
The cause was two libraries with the same name Adafruit_TinyUSB_arduino; one in arduino/libraries and the other one in ..\AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.8.5\libraries.
Then there was the return-key error. I used #define KEY_RETURN 40 to fix the problem.
import sys
#-------------------------------------------------
def backtrack(): # curr_col == 8
global curr_row
global curr_col
board[curr_row][7] = ' ' # remove queens from last row
curr_row -= 1 # down one row
if (curr_row < 0):
end_of_the_game("row number less than 0 (zero)")
curr_col = queens[curr_row] # get col value from queens
board[curr_row][curr_col] = ' ' # clean board from this row
curr_col += 1 # advance col
if (curr_col == 8):
backtrack()
#------------------------------------------
def print_board(num):
for i in range(7,-1,-1):
print('|', end="")
print ('|'.join(board[i]), end ="")
print('|')
print(f"------------------------------{num}------")
#-----------------------------------------------------
def check_position(row,col):
for y in [x for x in range(8) if x != col]: # row check
if board[row][y] == 'Q':
#print(row,y)
return False
for x in [y for y in range(8) if y != row]: # column check
if board[x][col] == 'Q':
#print(row,y)
return False
x = row + 1
y = col + 1
while (x < 8 and y < 8): # right & up
# 1,3 2,4 3,5 4,6 5,7 6,8
# 3,1 4,2 5,3 6,4 7,5 8,6
if board[x][y] == 'Q':
#print(row,y)
return False
x += 1
y += 1
x = row - 1
y = col - 1
while (x > -1 and y > -1): # left & down
if board[x][y] == 'Q':
#print(row,y)
return False
x -= 1
y -= 1
x = row + 1
y = col - 1
while (x < 8 and y > -1): # right & down
if board[x][y] == 'Q':
#print(row,y)
return False
x += 1
y -= 1
x = row - 1
y = col + 1
while (x > -1 and y < 8): # left & up
if board[x][y] == 'Q':
#print(row,y)
return False
x -= 1
y += 1
#print(row,y)
return True
#-----------------------------------------------
def end_of_the_game(msg):
print (f"{msg}: exiting")
sys.exit(0)
#--------------INIT-----------------------------
curr_row = 0 # start at the first row
curr_col = 0 # start at the first column
board = list() # init
queens = list() # init
for x in range(8):
board.append([]) #creates new row before populate
for y in range(8):
board[x].append(' ')
for x in range(8):
queens.append(0)
# start here, set row = 0 board[0][0]='Q'
# when row > 7 print board and
# set row = 7 and advance curr_col
# stop when row = -1
queens[curr_row]=0
curr_col = 0
board[curr_row][curr_col] = 'Q'
sol = 0
while (True): # end of game happens in backtrack()
while (curr_row < 8):
while (check_position(curr_row,curr_col) == False): # while False advance col
board[curr_row][curr_col] = ' '
curr_col += 1
if (curr_col == 8):
backtrack()
queens[curr_row]=curr_col
board[curr_row][curr_col] = 'Q'
curr_row += 1 # go to next row and check
curr_col = 0
# end of while
sol += 1 # number of solutions
print_board(sol) # row == 8, col = 0
# end of while (curr_row < 8)
curr_row = 7
curr_col = queens[curr_row]
board[curr_row][curr_col] = ' '
curr_col += 1
if (curr_col == 8):
backtrack()
queens[curr_row]=curr_col
board[curr_row][curr_col] = 'Q'
https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
After uploading a sketch with an external clock (16 or 20Mhz) and you want to go back to an internal clock you have to attach the crystal when uploading the next sketch or you get an Device signature = 0xff00ff error.