Skip to content

Conversation

@Joe7M
Copy link
Contributor

@Joe7M Joe7M commented Nov 24, 2023

Hi Chris,

I wanted to use image.clip() and image.save() to split a tilemap into tiles but realized, that it was not possible. I did some improvements to the image save function. Now you can do the following:

png.save("horse1.png")
png.save(#1)
png.save(byref var)
file = "abc.png" : png.save(file)

Especially the last line was not possible. When a variable was passed as an argument, the variable was always transformed to an array and the image values were returned in this array. When now a string-variable with a file name is given as an argument, the file will be save to that file name.

Additionally when saving to an array, the settings of image.clip will be applied instead of returning the full image.

At the moment I did it only for image.cpp in the ui folder. If you like the changes, I can also rewrite the console part.

Best regards, Joerg

@Joe7M
Copy link
Contributor Author

Joe7M commented Dec 1, 2023

In the second commit, I fixed a bug in image.clip(), which crashes SB, when providing negative coordinates. I also added some bound checks for image.save().

@Joe7M
Copy link
Contributor Author

Joe7M commented Dec 1, 2023

In the third commit I fixed a bug when opening a serial port: When using COMx, SB opened COM(x-1) : COM5 -> COM4.

@Joe7M
Copy link
Contributor Author

Joe7M commented Jan 13, 2024

Hi Chris,

one more commit. This time I improved the serial port. I wanted to connect to a Raspberry Pi Pico in Linux. I realized, that this is not possible, because the Pico creates a serial port called /dev/ttyACMn and SmallBASIC was only able to open /dev/ttySn. The same for Arduino. Some other devices creating a serial port /dev/ttyUSBn. So I started to improve the serial port in Linux and Windows. Here the changes:

  • [Linux] /dev/ttyUSBn, /dev/ttyACMn and other serial port devices starting with /dev/tty can now be opened: open "/dev/ttyUSB1:9600" as #1"
  • [Windows] COM-port 10 to 99 can be opened
  • [Windows] serial connection with Raspberry Pi Pico using the Pico's USB-port is working now
  • [Linux and Windows]: Baud rate can be set to values higher than 38400 (up to 4000000)

I tested in Linux Manjaro and Windows 11 using Arduino Uno, Raspberry Pi Pico and Adafruit Feather M0 Express.

Best regards, Joerg

@chrisws
Copy link
Contributor

chrisws commented Jan 13, 2024

Looks good.

Sorry I only recently notices this PR.

Cheers,
Chris

@chrisws chrisws merged commit f7528be into smallbasic:master Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants