Close
0%
0%

MachiKania type P

MachiKania type P (aka MachiKania phyllosoma) runs a BASIC compiler on Raspberry Pi Pico to control LCD, MMC etc

Similar projects worth following
MachiKania type P (aka MachiKania phyllosoma) runs a BASIC compiler (structured and object oriented BASIC language) on Raspberry Pi Pico to control LCD, MMC, and other peripherals (SPI, I2C, PWM UART, and ADC).

This project is a collaboration with KenKen (https://github.com/KenKenMkIISR/).

MachiKania type P is an open platform that runs BASIC program on Raspberry Pi Pico ($4!). It is connected to 320x240 LCD and MMC/SD card, so it can read files in the card and displays the result of BASIC program execution on the LCD.

The source code and ZIP archive package are available in GitHub page ( https://github.com/machikania/phyllosoma ).

The BASIC isn't an interpreter but compiler. The BASIC system (aka KM-BASIC) compiles BASIC codes to ARM Cortex-M0 native code for the fastest execution speed.

The BASIC language is compatible to the ones of the other MachiKania computers (type M, type Z, and web), so the programs are easily transported among the types.

This photo shows an example of running a game BASIC program, SPACE ALIEN (provided as a sample in ZIP package). KM-BASIC provides the enough speed to run many games written in BASIC as it generates ARM native code.
The LCD is 320x240 resolution; 256 color photo can be displayed by BASIC code (full color photo can be also shown by a small hacking).

This is the initial screen. One can select a file by the cursor buttons (blue and green ones in picture) and run it by the fire button (red in picture). To view the source code of BASIC file, press the start button (yellow in picture).

You can also connect an USB keyboard to MachiKania (photo by KenKen). The built in editor let you be able to create or edit BASIC program. Therefore, MachiKania can be also used as a stand alone PC.

From the ver 1.3.0, MachiKania type P support the connection to internet by using Raspberry Pi Pico W. When connected to NTP server, real time clock (RTC) can be also used. Two useful classes in library make the connection to internet easy: WGET and HTTPD, used as client and server, respectively.


The syntax of BASIC language is described in help-e.txt file in documents folder of ZIP archive (repository: https://raw.githubusercontent.com/machikania/phyllosoma/main/documents/help-e.txt). The help file is translated by computer from Japanese one. Therefore, if there are somethings wrong, or confusing, please let me know.

The BASIC language supports following programing styles:

  • classical line number BASIC
  • structured BASIC
  • object oriented BASIC (class based)

For the detail of object oriented programing, please refer class-e.txt in document folder (https://raw.githubusercontent.com/machikania/phyllosoma/main/documents/class-e.txt).

MachiKania type P can be used as not only a game console but also an I/O controller. By simple BASIC codes, one can control SPI, I2C, UART, PWM, and A/D converter.

REM SPI LED Matrix x8 (MAX7219 LED Driver)
SPI 10000,16,0:REM 10MHz/16bit/Mode0

REM Not Test Mode
D=$0F00:SPIWRITE D,D,D,D,D,D,D,D

REM Not Shutdown Mode
D=$0C01:SPIWRITE D,D,D,D,D,D,D,D

REM No Decode Mode
D=$0900:SPIWRITE D,D,D,D,D,D,D,D

REM Set Briteness
D=$0A05:SPIWRITE D,D,D,D,D,D,D,D

REM Scan All LEDs
D=$0B07:SPIWRITE D,D,D,D,D,D,D,D

DIM F(63)
RESTORE FONTDT
FOR I=0 TO 63
 F(I)=CREAD()
NEXT

FOR Y=0 TO 7
 D=(Y+1)<<8
 SPIWRITE D+F(Y),D+F(8+Y),D+F(16+Y),D+F(24+Y),D+F(32+Y),D+F(40+Y),D+F(48+Y),D+F(56+Y)
NEXT
END

LABEL FONTDT
CDATA $38,$6C,$C6,$FE,$C6,$C6,$C6,$00:REM A
CDATA $FC,$66,$66,$7C,$66,$66,$FC,$00:REM B
CDATA $3C,$66,$C0,$C0,$C0,$66,$3C,$00:REM C
CDATA $F8,$6C,$66,$66,$66,$6C,$F8,$00:REM D
CDATA $FE,$C0,$C0,$F8,$C0,$C0,$FE,$00:REM E
CDATA $FE,$C0,$C0,$F8,$C0,$C0,$C0,$00:REM F
CDATA $3C,$66,$C0,$CE,$C6,$66,$3C,$00:REM G
CDATA $C6,$C6,$C6,$FE,$C6,$C6,$C6,$00:REM H

Photo is an example of controling LED-tape (containing 144 LEDs) by MachiKania type P (programmed by KenKen). For a movie, please refer this page.

Following is an example to connect to internet. Here, the BASIC program uses WGET and JSON classes. Raspberry Pi Pico W is used.

useclass JSON,WGET
usevar Min0,Max0,Fstr0
usevar Min1,Max1,Fstr1

if val(strftime$("%Y"))<2023 then ntp

j$=WGET::FORSTRING$("https://www.recfor.net/projects/weather/tokyo.php")
REM j$=WGET::FORSTRING$("https://www.recfor.net/projects/weather/osaka.php")
...
Read more »

  • 1 × Raspberry Pi Pico
  • 1 × ILI9341 LCD (SPI interface) - MMC/SD card slot combo
  • 1 × MMC/SD card
  • 1 × PCB board
  • 2 × 20 pin male headers

View all 17 components

  • Ver 1.4.0

    Katsumi02/21/2024 at 20:49 0 comments

    MachiKania type P ver 1.3.1 was released on 2/17/2024.

    • FILEMAN.BAS (file manager) was added as a sample program.
    • Added BUTTON (button operation), GEN3O (Genkaku Gothic display), QRCODE (QRCODE display), and TSC2046 (touch panel operation) to the class library. 
    • Enabled to use spi1 with SPI instruction when LCD is not used. 
    • Fixed a bug in PUTBMP instruction when displaying a long width image. 
    • The file modification date and time can be displayed in the file list view. 
    • The display order of file names and modified dates in the file list display is now supported. 
    • Fixed a display bug on ILI9488 LCD when it is displayed in portrait mode.  The FRENAME and MKDIR instructions and the FRENAME() and MKDIR() functions have been added. 
    • Auxiliary code (auxcode) can be added.

  • Ver 1.3.1

    Katsumi02/21/2024 at 20:47 0 comments

    MachiKania type P ver 1.3.1 was released on 10/28/2023.

    • The BASIC program for embed now supports file reading.
    • The number of files that can be embedded for embedding has been increased to 16. 
    • Fixed a bug that caused wrong values when displaying floating points and handling strings.

  • Ver 1.3.0

    Katsumi02/21/2024 at 20:44 0 comments

    MachiKania type P ver 1.3.0 was released on 9/30/2023.

    • WEATHER.BAS (get weather forecast from web), HDEAMON.BAS (construct web server) were added as a sample program.
    • Added HTTPD (construct HTTP deamon), IR_RX (IR receiver), IR_TX (IR transmitter), JSON (analyze JSON string) and WGET (web browsing) to the class library.
    • Added support for WiFi connection using Raspberry Pi Pico W. Following statements/functions are added: DNS$(), IFCONFIG$(), NTP, TCPACCEPT(), TCPCLIENT, TCPCLOSE, TCPRECEIVE, TCPSEND, TCPSERVER, TCPSTATUS, TLSCLIENT, WIFIERR(), WIFIERR$()
    • Fixed a bug in GCOLOR() function.
    • Fixed a key input bug with some USB keyboards. 
    • FGETC() function returns -1 when EOF. 
    • Supported XIAO RP2040, RP2040-Zero, and Tiny-2040 for embedding. 
    • SPI ports can now be specified in the INI file. 
    • Fixed a bug when the third argument of SERIAL statement is omitted. 
    • Exceptions are now trapped and displayed on the screen. 
    • Fixed a bug that CORETIMER starts to fail about 2000 seconds after power-on. 
    • Support ILI9488. 
    • Support RTC(Real Time Clock). Follosing statement/functions are added: GETTIME$(), SETTIME. STRFTIME$() 
    • Supports date/time setting when saving files. 
    • Supports RTC setting by NTP server. 
    • Supports turning on/off the LEDs attached to the board by calling SYSTEM 201. 
    • Fixed a memory allocation bug. 
    • Fixed a garbage collection bug when using file-related commands such as FREMOVE/SETDIR. 
    • Improved stability of the WAVE player. 
    • Fixed a static method call bug in a class. 
    • Three functions, FFINGD$(), FINFO(), and FINFO$(), are added. Enabled to create file list. 
    • Fixed a compile-time bug when the REM statement contains double quotation.

  • Ver 1.2.0

    Katsumi02/21/2024 at 20:40 0 comments

    MachiKania type P ver 1.2.0 was released on 1/28/2023.

    • USB keyboard and editor support
    • Added INKEY(), READKEY(), and INPUT$() functions and INKEY interrupt function.
    • Fixed a bug that occurred in some environments when compiling class files.
    • Added ALIGN4 statement, DATAADDRESS() function, and FUNCADDRESS() function.
    • Fixed a slight timing discrepancy in timer interrupt.
    • Added memory allocation related functions to SYSTEM().
    • Added a function related to memory allocation to SYSTEM().
    • Supported OPTION CLASSCODE.
    • Card can be inserted and removed during BASIC program execution.
    • HEX files created in C language can be loaded on the file selection screen.
    • Four classes, CRDINI, CLDHEX, REGEXP, and STRING, are added to the library.

  • Ver 1.1.0

    Katsumi10/02/2022 at 23:28 0 comments

    MachiKania type P ver 1.1.0 was released on 10/01/2022.

    • Fixed a bug that prevented compiling when using another class in a class
    • Fixed a bug in static function calls of the class
    • Allow assignment of strings and arrays to object fields
    • Fixed a bug that WAVE files stop playing after a certain period of time
    • Allows use of WAIT, DELAYMS, and DELAYUS statements during interrupts
    • Fixed a bug that caused MUSIC statements to stop with an error in some environments
    • The NOT#() function was added.

  • Ver 1.0.0

    Katsumi10/02/2022 at 23:27 0 comments

    MachiKania type P ver 1.0.0 was released on 8/27/2022. This is the first published version.

View all 6 project logs

  • 1
    Construct your board

    Construct your own board according to the circuit:schematic.png

  • 2
    Get the ZIP archive and copy the files to MMC/SD card
  • 3
    Install the MachiKania type P firmware

    Drag & drop the "phyllosoma.uf2" in ZIP archive to RPI-RP2 drive of Raspbery Pi PIco

View all 4 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates