-
Notifications
You must be signed in to change notification settings - Fork 155
Home
Welcome to the Ka-Radio32 wiki!
Version 1.5 and up of KaRadio32 allows you to configure gpio's and two custom IR keys per action.
This allows you to take advantage of the standard software even if your port configuration and/or your remote control are not the same.
The configuration must be specified in a csv file.
A template is given by the pattern.csv file
The default configuration of the current software is in the standard_adb.csv file.
A csv file is interpreted by an utility to generate a bin file that must be flashed at address 0x3a2000 only one time per esp32
The msys32 and esp-idf environment must be operational.
First, make sure you have an updated partitions.bin file. This file contains the system partitions:
$ make partition_table
Toolchain path: /opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: crosstool-ng-1.22.0-80-g6c4433a5
Compiler version: 5.2.0
Python requirements from C:/msys32/home/jp/esp/esp-idf/requirements.txt are satisfied.
Partition table binary generated. Contents:
*******************************************************************************
# Espressif ESP32 Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,16K,
otadata,data,ota,0xd000,8K,
phy_init,data,phy,0xf000,4K,
ota_0,app,ota_0,0x10000,1792K,
ota_1,app,ota_1,0x1d0000,1792K,
device,64,0,0x390000,4K,
stations,65,0,0x391000,64K,
device1,66,0,0x3a1000,4K,
hardware,data,nvs,0x3a2000,8K,
*******************************************************************************
Partition flashing command:
python /home/jp/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port com5 --baud 460800 --before default_reset --after hard_reset write_flash 0x8000 /home/jp/esp/Ka-Radio32/build/partitions.bin
************************************************ *****************************
Compared to an old version, it adds the declaration of the partition "hardware" which interests us.
Rename the pattern.csv file with the name of your c
ard, for example lolin32.csv
Beware: not comment line or empty line allowed in a csv file.
The declaration of gpio's is a not so easy task.
Any error results in an incorrect start of the software.
If the software does not start properly, please check your values.
A common mistake is to declare the same number for two functions.
See the log on the serial interface.
Edit this file to enter your gpio definitions.
See gpio.h for the default values if missing in the csv file.
Only modify the lines beginning with P_ by modifying only the last number.
for example:
P_MISO, data,u8,19
Change 19 to the desired number.
Do this for all P_ lines.
Never change the string "P_XXXX, data,u8,"
A value base 10 is mandatory for each P_.
SPI Bus:
K_SPI Select the used spi : 1: HSPI, 2: VSPI
P_MISO Master Input, Slave Output
P_MOSI Master Output, Slave Input Named Data or SDA or D1 for oled
P_CLK Master clock Named SCL or SCK or D0 for oled
VS1053B:
P_XCS XCS
P_RST RST
P_XDCS XDCS
P_DREQ P_DREQ
ENCODERS 0 & 1:
P_ENC0_A pin A clk
P_ENC0_B pin B Data
P_ENC0_BTN pin SW
P_ENC1_A pin A clk
P_ENC1_B pin B Data
P_ENC1_BTN pin SW
BUTTONS PANEL 0 & 1 of three buttons (switch to gnd):
P_BTN0_A click:start/stop, double click:toggle, help: station
P_BTN0_B click: +
P_BTN0_C click: -
P_BTN1_A start/stop, toggle, volume
P_BTN1_B +
P_BTN1_C -
Bus I2C (Oled & Lcd):
P_I2C_SCL SCL or SCK
P_I2C_SDA SDA
P_I2C_RST RST if any
LCD on SPI bus:
P_LCD_CS CS
P_LCD_A0 A0 or D/C or DC
P_LCD_RST RST or RES
Infrared remote:
P_IR_SIGNAL ir Y Signal
I2S bus:
P_I2S_LRCK LRCK
P_I2S_BCLK BCLK
P_I2S_DATA DATA
ADC keyboard:
P_ADC gpio32 to 39 or 255 if not used.
LCD Backlight:
P_BACKLIGHT GPIO of the hardware device.
K_SPI,data,u8,2
2 is the spi VSPI_HOST (default)
1 is the spi HSPI_HOST
The spi bus is initialized in any case. It used for the vs1053 and/or the LCD if needed.
Two encoders maximun are supported, each with different actions:
Encoder0: the volume control and stations change when pushed and held,
Encoder1: the station control and volume change when pushed and heldi.
If P_ENC0_A = 255 the encoder (P_ENC0_A, P_ENC0_B, P_ENC0_BTN) is disabled (not used, the gpio's may be reused elsewhere).
If P_ENC1_A = 255 the encoder (P_ENC1_A, P_ENC1_B, P_ENC1_BTN) is disabled (not used, the gpio's may be reused elsewhere).
If If P_ENC0_A is not 255 and P_ENC0_BTN = 255, the push button is disabled.
If If P_ENC1_A is not 255 and P_ENC1_BTN = 255, the push button is disabled.
Two set of three buttons can be configured in place or with encoder(s). The only limit is the available gpio's.
Each set has functions equivalent to Encoder0 and Encoder1:
click on button A: Start/Stop playing
click on button B and C: volume down and up for set 0 (P_BTN0), Station down and up for set 1 (P_BTN1)
held on button A: click on button B and C: volume down and up for set 1 (P_BTN1), Station down and up for set 0 (P_BTN0)
If a set is not used, P_BTNx_A must be set to 255. In this case P_BTNx_B P_BTNx_C are disabled too.
If I2C is not used (ie no lcd or spi lcd) the gpio of the i2C can be reused elsewhere.
If not used P_XCS must be set to 255. Gpio of P_RST P_XDCS P_DREQ may be reused elsewhere.
If IR remote control is not used P_IR_SIGNAL must be set to 255
If the ADC keyboard is missing, set P_ADC to 255.
Compatible with https://github.com/…/Ka-…/blob/master/Hardware/controles.pdf and the one found at https://www.drive2.ru/b/487463808323813881/
The stop button is replaced with "Toggle Time/Infos" and "start replaced with "Start/Stop"
The ESP32 ADC can be sensitive to noise leading to large discrepancies in ADC readings. To minimize noise, users may connect a 0.1uF capacitor to the ADC input pad in use
Thanks to Vadim Polyakovsky:
A small optional schematics update which allows to switch LCD backlight on and off in case of battery powered KaRadio. The switching off timeout in x sec could be defined by sys.lcdout("x") terminal command. The display and its' backlight will wake up automatically in case of new meta, encoder or IR event. This way the battery life on one charge will be extended. Obviously not needed for OLED displays and wall plug power socket operation. A software support is done by Jean-Pierre in the new custom.c file. A GPIO number could be chosen among not used ones and defined respectively. Enjoy!
This external device turns off the LCD backlight in addition to the screen clear.
Usefull if a battery is used.
If the hardware device is missing, set it to 255
If you use a remote control with different codes from the default ones, you can give your codes by key. Two codes per key are possible:
For example for the K_OK key
K_OK, data, string, 0xFF0040 0xFF0040
or
K_OK, data, string, 0xFF0040
if you only have one code per key.
or
K_OK, data, string,
if no code is given for the OK key
Never change "K_XXXX,data,string,"
Reminder: to see the code of a key on your remote control, change the log level to sys.logi
Press a key and see the log. You will see something like that:
I (1204396) addon: IR event: Channel: 0, ADDR: ff00, CMD: bf40 = FF0040, REPEAT: 0
Where FF0040 is the 0xFF0040 code needed.
The keys and actions are:
K_UP Change to next Station
K_LEFT Volume Down -5
K_OK Toggle play/Stop
K_RIGHT Volume up +5
K_DOWN Change to previous station
K_0 Enter number of the wanted station
K_1 Enter number of the wanted station
K_2 Enter number of the wanted station
K_3 Enter number of the wanted station
K_4 Enter number of the wanted station
K_5 Enter number of the wanted station
K_6 Enter number of the wanted station
K_7 Enter number of the wanted station
K_8 Enter number of the wanted station
K_9 Enter number of the wanted station
K_STAR Play
K_DIESE Stop
K_INFO Toggle time/info display
No comment is allowed in this csv file.
Save the csv file.
Some samples are in the boards directory.
Start the command
./nvs_partition_generator.sh yourname[.csv]
to generate build/yourname.bin
For example
./nvs_partition_generator.sh standard_adb
generates the build/standard_adb.bin file from the standard_adb.csv file
$ ./nvs_partition_generator.sh standard_adb
python ../esp-idf/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py standard_adb.csv build/standard_adb.bin 8KB
done
With ESP DOWNLOAD TOOL
or esptool.py command at address 0x3a2000
It seems that there is a problem with this ESP DOWNLOAD TOOL for flashing the bin alone.
In case of problem, flash it with another bin (bootloader.bin or KaRadio32.bin)
This binary is to flash one time and on each modification of the csv.
Now you can enjoy the standart OTA. No needs to generate your own KaRadio32.bin.
JP 2018
Any browser or wget can be used to send basic commands to the webradio.
A command format is http://yourip/?command[&command]
If a command return some informations, it must be the last of the list or alone.
- version : return 'Release: x.x, Revision: x'
- infos : return
vol: 46 :the current volume
num: 240 :the current station number
stn: Hotmix 80 :the name of the current station
tit: BANANARAMA - Venus :the title of the son playing
sts: 1 :the state of the player: 0 stopped, 1: playing. - list=xxx : return the name of the station xxx (0 to 254)
- stop : stop playing the current station.
- start : start playing the current station.
- next : play the next station
- prev : play the previous station
- play=xxx : with xxx from 0 to 254 play the station xxx
- volume=xxx : with xxx from 0 to 254 change the volume to xxx
- uart : uart baudrate at 115200 not saved on next reset
- instant="http://your url" : instant play a site
Example: http://192.168.1.253/?instant=http://api.voicerss.org/?f=32khz_16bit_stereo&key=29334415954d491b85535df4eb4dd821&hl=en-us&src=hello?the-sun-is-yellow?and-i-like-it"
the url must begin with http:// and be surrounded by " and no space char allowed.
Volume may be combined with other command.
Example: 192.168.1.253/?volume=50&play=128&infos
Reminder: the url without parameter is the full web interface.
The serial inteface can be used to receive events from the webradio and to send commands to it.
The telnet interface is reached by the port 23.
The serial interface adds the logs output of the tasks.
Example of indications received:
##CLI.STOPPED# from playStationInt
##CLI.NAMESET#: 88 Public Domain Classical - Swiss Internet Radio
##CLI.URLSET#: 82.197.165.137
##CLI.PATHSET#: /
##CLI.PORTSET#: 80
##CLI.OVOLSET#: 0
##CLI.VOL#: 110
##CLI.ICY0#: Public Domain Classical - Swiss Internet Radio - Shoutcast Streaming Technology by www.init7.net
##CLI.ICY1#: <BR>This stream requires <a href="http://www.winamp.com/">Winamp</a><BR>
##CLI.ICY2#: SHOUTcast Distributed Network Audio Server/Linux v1.9.8<BR>
##CLI.ICY3#: http://publicdomainproject.org
##CLI.ICY4#: Classical
##CLI.ICY5#: 128
##CLI.META#: Felix Mendelssohn-Bartholdy - String Quartet in E flat major Op. 44 No.3: 4. Molto allegro con fuoco
##CLI.PLAYING#
##CLI.STOPPED# from playStationInt
##CLI.NAMESET#: 92 ALBUMROCK.MIAMI
##CLI.URLSET#: uk4.internet-radio.com
##CLI.PATHSET#: /
##CLI.PORTSET#: 8081
##CLI.OVOLSET#: 0
##CLI.VOL#: 110
##CLI.ICY0#: ALBUMROCK.MIAMI
##CLI.ICY1#: <BR>This stream requires <a href="http://www.winamp.com/">Winamp</a><BR>
##CLI.ICY2#: SHOUTcast Distributed Network Audio Server/Linux v1.9.8<BR>
##CLI.ICY3#: www.AlbumRock.Miami
##CLI.ICY4#: Classic Rock 60s 70s 80s Miaimi Florida Album Rock
##CLI.ICY5#: 128
##CLI.META#: The Who - Eminence Front
##CLI.PLAYING#
#CLI.LIST#
#CLI.LISTINFO#: 2: RTL2, streaming.radio.rtl.fr:80/rtl2-1-44-128.m3u
##CLI.LIST#
(cli.info) typed
##CLI.NAMESET#: 92 ALBUMROCK.MIAMI
##CLI.ICY0#: ALBUMROCK.MIAMI
##CLI.ICY1#: <BR>This stream requires <a href="http://www.winamp.com/">Winamp</a><BR>
##CLI.ICY2#: SHOUTcast Distributed Network Audio Server/Linux v1.9.8<BR>
##CLI.ICY3#: www.AlbumRock.Miami
##CLI.ICY4#: Classic Rock 60s 70s 80s Miaimi Florida Album Rock
##CLI.ICY5#: 128
##CLI.ICY6#:
##CLI.ICY7#:
##CLI.META#: The Who - Eminence Front
##CLI.VOL#: 108
##CLI.PLAYING#
##CLI.META#: The Beatles - Mother Nature's Son
##SYS.TZO#: 1
##SYS.DATE#: 2017-04-13T22:47:44+01:00
with ICYx: 0:"icy-name:", 1:"icy-notice1:", 2:"icy-notice2:", 3:"icy-url:", 4:"icy-genre:", 5:"icy-br:", 6:"icy-description:", 7:"ice-audio-info:"
Some other informations may be printed for debug purpose, but usefull events always start with ##
wifi.list : give the list of received SSID
wifi.con : Display the AP1 and AP2 SSID
wifi.con("ssid","password") : Record the given AP ssid with password in AP1 for next reboot
wifi.discon : disconnect the current ssid
wifi.station : the current ssid and password
wifi.status : give #WIFI.STATUS# start of the answer
5 the connection state
192.168.1.40 the current ip
255.255.255.0 the network mask
192.168.1.70 the network gateway
##WIFI.STATUS# end of the answer
wifi.rssi : print the current rssi (reception level)
// instant play
cli.url("url") : the name or ip of the station to instant play
cli.path("/path") : the path of the station to instant play
cli.port("xxxx") : the port number of the station to instant play
cli.instant: : play the instant station
// Stations play
cli.start : start to play the current station
cli.play("xxx") : play the xxx recorded station in the list (0 = stop)
cli.prev (or cli.previous) : select the previous station in the list and play it
cli.next : select the next station in the list and play it
// Station stop
cli.stop : stop the playing station or instant
// station list
cli.list : list all recorded stations
cli.list("x") : list only one of the recorded stations. Answer with #CLI.LISTINFO#: followed by infos
// volume commands
cli.vol("xxx") : set the volume to xxx with xxx from 0 to 254 (max volume)
cli.vol : ask for the current volume. respond with ##CLI.VOL# xxx
cli.vol- : Decrement the volume by 10
cli.vol+ : Increment the volume by 10
Every vol command from uart or web or browser respond with ##CLI.VOL#: xxx
// Client information
cli.info : Respond with nameset, all icy, meta, volume and stae playing or stopped. Used to refresh the lcd informations
: see Example of indications received
sys.uart("x") : Change the baudrate of the uart on the next reset.
Valid x are: 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 76880, 115200, 230400
sys.i2s : Display the current I2S speed
sys.i2s("x") : Change and record the I2S clock speed of the vs1053 GPIO5 MCLK for the i2s interface to external dac.
: 0=48kHz, 1=96kHz, 2=192kHz, other equal 0
sys.erase : erase all recorded configuration and stations.
sys.heap : show the ram heap size
sys.update : start an OTA (On The Air) update of the software
sys.prerelease : start an OTA of the prerelease for test purpose.
sys.boot : reboot the webradio.
sys.patch("x") : Change the status of the vs1053 patch at power on.
0 = Patch will not be loaded, 1 or up = Patch will be loaded (default) at power On
sys.patch : Display the vs1053 patch status
sys.led("x") : Change the led indication:
1 = Led is in Play mode (lighted when a station is playing), 0 = Led is in Blink mode (default)
sys.led : Display the led indication status
sys.tzo("xx") : Set the timezone offset of your country.
sys.tzo : Display the timezone offset
sys.date : Send a ntp request and Display the current locale time
: Format ISO-8601 local time https://www.w3.org/TR/NOTE-datetime
: YYYY-MM-DDThh:mm:ssTZD (eg 2017-07-16T19:20:30+01:00)
sys.adc : Read the current value of the adc input. (Not for KaRadio32)
sys.log : Do nothing. Used for debug of the addon.
sys.version : Display the release and Revision of KaraDio
sys.host : display the hostname for mDNS
sys.host("your hostname"): change and display the hostname for mDNS
<enter> will display
#INFO:""#
help : list the available commands.
A command error display:
##CMD_ERROR#
sys.dlog : Display the current log level
sys.logx : Set log level to x with x=n for none, v for verbose, d for debug, i for info, w for warning, e for error
sys.lcdout : Display the timer to switch off the lcd. 0= no timer
sys.lcdout("x") : Timer in seconds to switch off the lcd. 0= no timer
sys.lcd : Display the current lcd type
sys.lcd("x") : Change the lcd type to x on next reset
sys.ledgpio : Display the default Led GPIO
sys.ledgpio("x"): Change the default Led GPIO (4) to x
sys.ddmm: display the date format
sys.ddmm("x"): Change the date format. 0:MMDD, 1:DDMM
sys.rotat: display the lcd rotation option
sys.rotat("x"): Change and display the lcd rotation option (reset needed). 0:no rotation, 1: rotation
sys.henc0 or sys.henc1: Display the current step setting for the encoder. Normal= 4 steps/notch, Half: 2 steps/notch
sys.henc0("x") with x=0 Normal, x=1 Half
sys.henc1("x") with x=0 Normal, x=1 Half