Labels

Sunday, 11 September 2022

6502 Terminal

ACIA Serial Chip

My working 6502 system needs some input / output capability.  Ben Eater added a VIA (Versatile Interface Adapter) and attached an LCD display to his system.  I prefer to start with an ACIA (Asynchronous Communication Interface Adapter).  This provides me with a serial interface running at 19200 baud.

An ACIA chip was added to the breadboard and connected using an FTDI chip to a PC USB COM port.  The hardware allows me to use a Windows Terminal or Putty session providing a screen and keyboard interface.  I could attach a physical terminal, but they don't really exist anymore and a PC terminal session works just fine.  I did build a physical terminal using an LCD screen a while ago but I don't need it here.

Arduino Testing

My inspiration for the ACIA connection is Dirk Grappendorf who provides an excellent description and code to terminal I/O.  

To check my breadboard connections I designed a sketch which ran on the Mega without the need to use my CPU.  In fact I did have trouble getting the ACIA to work as an extra capacitor is required which Herr Grappendorf mentioned but I omitted as it wasn't shown on the datasheet.

The ACIA is controlled in a very simple manner.  Two bytes are written to the command and control registers specifying communication parameters.  Subsequently bytes which are inserted in the transmission register are sent to the FTDI and onwards to the PC terminal session.

6502 Machine Code


Once I was happy that wires and the ACIA were working I could write a very simple assembly program which writes the command register (address $4002) the control register (address $4003) and then loops to output a character (0x34, the digit 4) in the data register (address $4000).






The result is a 17 byte program which puts a steady stream of characters out on the terminal.  There isn't any synchronisation by the program to ensure that the terminal is ready for the next character before transmitting it, we simply send characters as fast as we can.


Add RAM

We dont actually require RAM for this version of the program to work.  RAM is required for the 6502 stack, which is used by the subroutine mechanism to store return addresses.  Adding a subroutine to the program allows us to check that RAM is still working.

Clock Speed

Initial testing is carried out using the Ben Eater clock, which is a 555 timer based solution which runs at speeds upto about 200Hz.  Previously I have built an Arduino nano-based clock which allows me to choose between a number of speeds 5 Hz, 50 Hz, 500 Hz and 5000 Hz.  When I substituted the nano clock into the system I found that it worked.  However, as expected, the system didn't work when the full-speed 1 MHz clock chip was connected.

Summary  

We have added a terminal to our 6502 system so that we can do input / output.  We wrote a very simple machine code program as a first test that output to the terminal works.  Normally the "terminal driver" would synchronise transmission and receiving but we had good results with a 5 KHz clock sending characters as fast as we could.
What we really need is a software environment to assemble and load programs so that we can better, more extensive programs - this will come next.




Saturday, 10 September 2022

6502 stripboard circuit

 It is almost a year since I touched my 6502 systems.  I decided to step away as reliability problems were frustrating me greatly.  In particular programs didn't run reliably with the 1 MHz clock and I suffered repeated loose connections.  God knows how Ben Eater copes with his bread board circuits, I guess he must be so meticulous that all his connections are reliable.

Options

I considered various options to make my system more "permanent" and less error-prone:
 * Design  a PCB for my components and get it made up
    - this is too complicated for a first PCB creation, very difficult to be 100% accurate
 * Buy a PCB designed for these components
    - I did find one that looked promising by Jeff Tranter but opted to try the W65C02SXB instead
 * Buy a W65C02SXB which contains all the components I need
    - I did buy a board, and it is wonderful, but it is somewhat different to use
 * Use stripboard to create a permanent version of my working breadboard circuit.
    - This is the most reasonable way forward and one I have put a lot of effort into.

Stripboard

Stripboard generally comes in boards upto 38 columns wide with long tracks.  This isn't very convenient for soldering ICs as all the tracks have to be cut under each chip.  There are a few stripboards available (I only really looked on eBay) in breadboard style format.and I have purchased some of each type.  The main requirement is to have at least two holes, preferably three, on either side  of the larger chips to solder connections.

Layout

In theory I could just copy my existing breadboard chips and connections to stripboard.  In practice the first boards I found were not as wide as breadboard (which has 63 holes across) so I needed a different arrangement.  In addition the existing breadboard components weren't necessarily in the best positions so there were some potential improvements I could make.

As ROM and RAM share address and data bus connections and I have previously had problems with them I decided to create a ROM-RAM memory board with a NAND chip for control logic and off-board  bus and control connections to the 6502.  As an Arduino Mega is used for testing and to program ROMs it is best connected to the memory board.  Offboard connections will be made using dupont connectors terminated in male posts on the board.

It was a hard days work to draw a board diagram with chip locations and all necessary connections. In particular I needed to make sure that all 6502 pins required both for memory chips and those used by the Mega were available. Clearly any errors preventing the board working would be difficult to correct once it had been soldered.


Build


As an amateur at this business it was obvious that I should build the board in stages.  The first stage is to solder EEPROM and Arduino Mega connections.  The Mega is used to write code to ROM and the ROM can work in isolation from NAND, RAM and CPU.  I inserted a ROM chip (AT28C256) with known code onto the board and checked I could read it from the Mega and then wrote some new code to the ROM and read it back.

We can now solder remaining board connections.  





The NAND chip is used to select either RAM or ROM.  Our simplified memory map is:
   $0000-$3FFF   RAM
   $8000-$FFFF   ROM
so we use the address wires A15 and A14 in the NAND gates to enable/disable ROM and RAM.
A sketch is used to check that NAND inputs provide the correct control signals to ROM and RAM.  Another sketch, which is very similar to the ROM read sketch can then test reading and writing RAM. 

We are now confident our memory works and it is time to add the W65C02 CPU to the circuit.  We are not yet ready for a soldered version so the CPU and reset button are put onto a breadboard.  The CPU needs a clock, for which the trusty Ben Eater Clock circuit is used.

At this stage we are not using RAM, program instructions are loaded from ROM and executed by the CPU.








A monitor sketch is devised, running on the Mega, which displays address and data bus values after each clock cycle.

The 6502 datasheet explains that when Reset is pressed the CPU uses 6 clock cycles to initialise and then loads a reset vector from address $FFFC and $FFFD.  On the right you can see that cycles 6 and 7 load an address $8000 from these addresses and executes the (non-existent) program starting at $8000.

In fact, we previously used a Mega sketch to store data in the reset vector $FFFC=0x00 and $FFFD=0x80.  The 6502 uses "little-endian" addresses, which means that the low order address byte is stored first.  and the high order byte second so these values are correctly interpreted as address $8000.

Program Execution


We now write a simple assembly program to write some data in a loop and load it into ROM starting at address $8000 using the Mega.  The address values $6000 and $6002 shown below don't exist but that doesn't matter; using the Mega monitor we can watch each instruction being loaded and executed.
The picture below shows the source program and the hex machine code which it translates to - it is only 17 bytes in length.
On the monitor line #8 shows the first instruction being loaded/executed from address $8000.  The loop instruction "jmp loop" at address $800E-$8010 is executed in lines #26 to #28 and execution continues at address $800A.

Conclusion

This is great we have built a simple 6502 system with RAM and ROM on stripboard.  We have the CPU connected and a working monitor to show instructions being executed.  It is a big step forward in complexity and more more successful than previous efforts.  I have done this before following the inimitable Ben Eater videos but I have learned enough to put things together myself.

This is only a brief breathing space along the journey to make a useable system but it is the culmination of  some solid work and I am happy with the results so far.

The next step, which I can document shortly is to provide input / output capability and in particular to incorporate an ACIA serial terminal interface.


Monday, 25 July 2022

More MQTT Clients

We setup an MQTT broker on Home Assistant (HA) so that our Lily ESP32 super remote can communicate with it.  MQTT facilitates many different systems to interact and clients can communicate with each other as well as the broker.

Linux MQTT

RPi MQTT client installation is easy, I just install mosquitto-clients onto the RPi and I can send messages at the command line with mosquitto_pub.
If I use the same topic and message as Lily it has the same effect, for example in the example below I publish "button 3" to topic esp32/volume and HA arranges for the volume to be turned up on my Sony Amplifier.



This is great for testing but it is unlikely that I will use the linux command line much.  However I would like to send MQTT messages using a browser, this allows me to send messages from phone/ipad/pc.  

Browser MQTT

The Eclipse Paho MQTT javascript client appears to be a popular choice for a browser javascript MQTT client and Steves Internet Guide provides a very clear example to get a client working.  The browser javascript client communicates with websockets on the MQTT broker and after some searching I found that in addition to the MQTT port 1883, HA supports websockets and the broker websocket listener is on port 1884.

Using Steves Internet Guide it was easy to setup javascript MQTTconnect/disconnect functions, associated with buttons on a simple webpage.  The handlers required to deal with connection success / failure and incoming messages are also simple to implement so I can show the status of the connections and any messages received on a page.  Finally I provided"volume up" and "volume down" buttons to demonstrate that I can now control my amplifier volume by sending MQTT commands to HA so that it can tell the Broadlink IR sender to send volume up/down commands to the amplifier.

The result is the very simple test webpage shown below.  I can now easily implement MQTT functionality into other webpages which need to control devices in the home, in particular my home music server.

It is great that MQTT is a flexible general purpose communications protocol which will work for many different devices.

Webhooks

Early on in my HA investigations I setup webhooks so that I can trigger HA automations from a webpage.  At the time I was more interested in voice control using Google Assistant and webhooks duplicate what is more readily achieved through voice.

However it occured to me that if I can use parameters / arguments with webhooks they make a realistic alternative to MQTT for communication with HA. Webhooks communicate directly with HA rather than needing to connect to the MQTT broker and sending a payload.

HA documentation indicates that it is possible:


Webhooks are implemented using POST requests which I can most easily provide using a linux curl command

I had some difficulty seeing the payload in HA until I added the -H parameter to specify JSON format.  However once this was resolved I could write an automation which displays the payload trigger.json.payload as a HA notification when the message is received.

Of course I want to use webhook URLs in a webpage so I coded a form to send an input text box named payload.  In this case the item containing the information is trigger.data.payload.  Rather than sending an input text field I can add one or parameters to the webhook URL containing directives for HA.  I added a parameter called arg to the webhook URL and could access it in a HA template as trigger.query.arg.  The example below shows both the form item payload and the URL arg being sent from a webpage.  The URL arg is displayed as a HA notification whilst the payload is sent to Google Nest mini to be read aloud.


Implementation


This is great, I can add a variety of fixed and variable information from a web page into a HA webhook automation.
My first implementation is an automation which carries out the same functions as the buttons on the Lily Remote Control to implement volume control and display LED patterns on my programmable LED display.  It is very quick and simple to set this up, only about 15 minutes from concept to testing.




Tuesday, 19 July 2022

LilyGo : Load Images from SD Card

 My LilyGo Genius Remote (smarter than a smart remote) is becoming more sophisticated as I investigate and utilise extra features.  It almost seems strange that I haven't used the SD card previously as programming in the non-Arduino world is often pre-occupied with files.
Lily comes with a demo sketch SD_Test which shows file and directory functions on an SD card so it was an easy matter to incorporate the SD card into my sketch and list / read  files.

As Lily has a small graphics screen, the factory_test demo sketch displays a logo as Lily starts up.  Data for the picture is provided by a header file in the demo sketch containing pixel values which are compiled with the sketch and loaded into a flash memory (PROGMEM) array so they can be displayed using the displayWrite method in the TFT_eSPI library.

To make my own picture I can use a utility program ImageConverter 565 . The screen size is 240w x 135h so my first step is to find an image and, using MS Paint, cut it down to 240 x 135 pixels, which is a rectangular shape.  ImageConvertor will the convert it to C format which is a statement defining a PROGMEM array with 32,400 16 bit data values.  I include this file as a header within my sketch and can then display it on the screen.



I potentially want to display a variety of pictures on the small screen so I would prefer to load the images from my SD card at run-time rather than compile and download them in a sketch.  ImageConverter can also create images in a ".raw" file format. The screen size is 240w x 135h and each pixel is 16 bits.  The RAW file contains no header or format information, just the pixels, so the file created is exactly 240 x 135 x 2 bytes = 64,800 bytes.

I remove the SD card from Lily and copy my image files on to it.  I like the fact that it is exactly 64,800 bytes, nothing at all is added to the file.  To load the image I simply have to read the file into an array and display it.  The ScreenBuffer array is 32,400 bit values so I have to read in two bytes to each array element.  I can then load an image whenever I want.



I cant stress enough what a wonderful hardware package LilyGo is for ESP32 development.  I think LilyGo are a maker / hobbyist company, but this device is potential usable in shops as a hand-held terminal.  I hope that this box or a similar one continues to be available.  As an added bonus the demo sketches show you how to use all the functions so you don't have to spend time looking for datasheets, pin numbers, libraries etc; making it childsplay to provide more functions.  I love it.

Monday, 11 July 2022

LilyGo Remote

 Previously I spent some time setting up my wonderful new LilyGo T-Display Keyboard functions, mainly to control my music server, similar to its pre-decessors.  It has a lot more potential and I have been starting to add features.

Screen Saver

As Lily works on battery when not connected to USB there is a limited amount of time before it needs to be recharged.  It is sensible to turn off the screen when not in use.  The factory_Test sketch which was provided with Lily shows how to turn the display off and put ESP32 into deep sleep mode


The first two commands DISPOFF and SLPIN blank Lilies LCD display and turn off power to the LCD.  I struggled to find documentation for these commands.  In fact they are well-documented in the ST7899V datasheet which corresponds to the LCD.  I can turn the screen back on with DISPON and SLPOUT commands.

So now I need to setup a proper screen saver.  It should wait until Lily has been inactive for a short while, say a minute and power down the screen.  When a key is pressed the screen should be powered on, allowing the user to continue.

I need a timer function to do this.  There are generic Arduino timer libraries but it is better to use the ESP32 timer function.  We set up a timer with an alarm so that the screen blanks after 10 seconds (during testing, 1 minute for real use).  If the user presses a key either before or after the screen blanks the timer is reset and the screen is restored so they can continue. 


This works very well, keyboard input is still possible when the screen is off so there is no delay in waiting for Lily to wakeup.  I have added some menus for favorite albums, radio stations and chart playlists so it is useful to have the screen on for this.  For some of the other functions I dont usually need the screen.

Hibernation

If Lily is not in use it can be put into a deep sleep where wifi is turned off and the CPU is using little current.  Initially I investigated shutting down functions before sleeping then waking up with an external interrupt when a button was pressed.  However I decided to simply set up a timer so that the ESP32 goes straight into deep sleep after an hour of inactivity with no wakeup capability.  If Lily is in use it is likely that a key will be pressed within an hour.  It only takes 5s-10s for Lily to start up so pressing the restart button on first use isn't an issue.

With Screen Saver and Hibernation working Lily is behaving like a real computer!  The battery lifetime is now at least two or three days.

Saturday, 9 July 2022

RISC-V Assembly input

 Previously I have managed to write an assembly program to display a range of memory locations.  A small next step is to work out how accept input to the program.  As I am using GLIBC these functions should be straightforward, in fact the simplist approach is to write a C program, see how the compiler has converted it to assembly then adapt it for my own program.

Character input

Step 1 is to read in a character from the terminal. Linux uses "blocking" input by default which means that you need to hit Enter after the character(s) before they are processed.




Command line arguments

Step 2 is to read input from command line arguments into the program.  Linux puts the arguments onto the stack for me - probably as part of the crt0 initialisation so I just need to decode the structure from the stack.


String Input

Step 3 is to read in a string from the terminal.  I can either use the stack to store the string or data storage within the program, I checked that both worked.

Non-blocking input

Finally I tried non-blocking input.  This required a bit more investigation within the C environment.  I found a beautifully clear tutorial written by Paige Ruiten as part of his snaptoken project to implement the kilo text editor.  I tinkered with his example to minimise it so that I could look at the assembly.

When someone shows you what to do it isn't too difficult but I wouldn't really like to work it all out for myself.  In fact I didn't implement this in assembly, but it is all ready for when I want to use it.

Libraries

Whilst working with these C and assembly programs I did think about how I use libraries.  I am using GLIBC in my assembly programs because I dont want to write lots of I/O routines but generally speaking this means I don't need to write assembly myself since my programs could be written in C.

However, using RISC-V, one of the benefits is being able to use native RISC-V assembly so I will continue to try a little bit.

If I write anything significant I should put it in a library.  I followed a very good opensource.com tutorial to familiarise myself with creating and using a Linux library.

HA : ESPHome : RFID Reader

 Previously, I installed ESPHome with a simple indicator, showing whether a GPIO pin was hi or lo.
Many devices we use with Home Assistant (HA) have specific home automation interfaces.  ESPHome extends HA functionality by providing an interfaces for many more sensor components which can measure the environment somehow.  ESPHome provides the capability to interact with RFID readers and cards / tags.

I purchased three RC522 readers on Ebay and they turned out to be very simple to setup.

I am using a ESP32-VROOM-32 as my ESPHome server device and it communicates with RC522 using SPI.  ESPHome is configured using HA.  Firstly we define the pins to be used for spi.  We can then add the pin required for RC522.  Using the ESPHome UI we tell HA to install this configuration and it spends a couple of minutes compiling an image and downloading it wirelessly to the ESP32.  I connected the 4 data pins plus 3V3 and GND from the ESP22 to the RC522 and ESPHome showed that it was communicating 😀😀😀


 The next stage is to present a keyring-tag or card to the reader.  When you do this the ESPHome console log shows the id.  You can add each tag uid as a binary sensor within ESPHome and then look at them on a dashboard.

Once we have binary sensors we can set up a HA automation which is triggered whenever the binary sensor state is changed.  My  initial experiment instructs the Google Nest Mini speaker to inform me when Tag 1 is presented to the reader and when it is removed.

There are ways we could use the cards.  I could present a card to the reader when I enter or leave the room and everything could be setup for me.  Baby Harry could have a variety of cards to do things when he wants them. 
I did check whether NFC on my phone is acceptable to the reader.  It does register and send a tag id to HA, but the tag is different each time, possibly as it uses more sophisticated security, so it isn't much use to me.



Wednesday, 22 June 2022

LilyGo T-Display Keypad


Rationale

Some years ago I setup a home music server based on Linux Music Player Daemon (MPD) with a web front-end to select and control music playing on my HiFi separates system.  Typically I would choose music to play using  my iPad or phone browser.
As an add-on I developed an ESP8266 attached keypad which also allowed me to control the music.  I call it my "Button" although it has a number of buttons/functions.  It is particularly useful for pause / resume, next type functions and to start my favourite playlists and radio channels.  Effectively it is a clever remote control tailored to suit my needs.
The original "Button" version 1 has a USB cable to power the ESP8266 so it isn't very portable; typically this doesn't matter but I did develop version 2 which has a rechargeable battery.  I found this cumbersome and I haven't used it much.  Both Buttons have a tiny LCD screen to display status info but this isn't very visible as I have had difficulty creating suitable enclosures to accomodate ESP8266/keypad/displays.


Recently I have implemented my Home Assistant (HA) Server, including MPD for music server control and Arduino based MQTT communication.  This allows me to control my HiFi from an ESP device and I added it to my "Button" software for testing purposes and it works fine. It works in parallel to my original application and has the potential for more functionality / flexibility.

In advance of doing more work on the button I looked out for a case for an ESP device and keypad which would be more compact than my home-made devices.  I was excited to stumble on the LilyGo T-Display Keypad on Aliexpress.
It is based on the ESP32, has a mechanical keyboard, a small TFT display and a rechargeable battery all in a neat case.  This is an absolutely perfect replacement for my old buttons and I ordered one immediately.

First look

Connecting the USB-C cable causes the ESP32 to start up.  A simple display appears allowing you to display wifi networks, input voltage or put the processor into a deep sleep.  There are two buttons adjacent to the TFT screen for these controls.  There is also a reset button on the top or right of the case.
Like a remote control there is no on / off switch which feels very strange to me.





The LilyGO github repository provides you with instructions to load the TFT library and example sketches into your PC Arduino development environment.
From there it is easy to compile and load the Factory_Test sketch which is the same one as installed on delivery.  This is awesome, nothing makes life easier than a working example containing many of the features of the device.  In particular it provides information on:
    All the pins needed for keypad, TFT, buttons, SD Card
    Arduino libraries for all hardware
    Example code to use the TFT display
    Example code to find the input reference voltage (useful for low battery check)
    Example to display a bitmap on the TFT
    How to put the ESP into deep sleep

In addition there are sketches for
    Example code to use the keypad
    Test SD functions to create, view, delete file and directory list.
    A rather good animated eyes sketch which makes really brings the screen to life.

This makes my life so much easier and saves me many, many hours looking at schematics, finding libraries, writing code to set up everything.

Application One

My first application requirement is clearly to setup similar functionality to the "Button".
Firstly I amended example code to read input from the keypad and display messages on the screen.  I then added wifi and websockets based on "Button 1" code.  Using a case statement I could then easily process key presses and send websocket messages to PI40 (which processes websocket input) for processing.  Within a few hours I have a working example for the "Button 3" based on the web page which I usually use.

I added and tested MQTT, using Home Assistant (HA) as my MQTT Broker.  This allows me to communicate with HA and use a HA script or automation to control any function HA function.  This is an extremely powerful extra.  On my webpage I cannot control amplifier volume since the amp is old and uses an IR remote control.  However my Broadlink IR remote is controlled by HA and I can add volume up/down buttons to LilyGo.

The LilyGo battery runs out after about 24 hours if not recharged, so I set up a button to show battery percentage / time remaining and another button to clear the screen.  This completes a basic setup which is a great improvement over my previous buttons and which I use in preference to my phone.

I cannot stress enough what a good product this is for me, both in terms of the hardware purchased and the software provided to help get started.  I shall look out for other products they can inspire me with.


     

 


Friday, 17 June 2022

Lu J Son

 Whilst on holiday, walking in the Pyrenees, we stopped for dinner at a lovely restaurant called El Montanes in Biescas.   As well as a wonderful dinner in a convivial surroundings the walls were decorated with some striking pictures.  As I was leaving I noted the pictures were signed by the artist LuJSon and I followed up on my return to England.

@Lu_J_Son is Tomas Langarita, who is from Zaragoza and may well teach there at the University. I contacted him via Instagram and found he has lot of beautiful work.  


In particular, in the restaurant I loved "8p.m.".  It is easily recognisable as lady on a sofa drinking a glass  of wine, with book shelves in the background.  There is a hint of Mondrian (who I dont like) in the white bookshelf grid.  The books are bright primary colours, neat but not regimented, random but harmonious, filling the top half of the frame.  The bottom half contains a grey sofa which is occupied by a lady, making herself comfortable with her feet up.  She is holding up a glass of good red wine which she is savouring.  Her posture, expression and mood are captured with a few straight line segments.  I think this is brilliant. I like the way that artists can capture meaning in single curves representing people or objects; this goes a step further capturing something extra from straight lines.  All the colours are outlined with black lines and it would be easy to translate the picture to stained glass fragments, joined / separated by lead joints (e.g. Sophie Taeuber-Arp work)

I have contacted Tomas and I may actually be able to buy this picture.  It would be lovely if this works.

In the meantime I have looked at more of his pictures some of which were at El Montanes....































Tuesday, 14 June 2022

HA : WLED

I purchased a WS2812B LED strip over a year ago.  The LEDs are individually addressable, allowing you to set up patterns on the lights.  I didn't get around to doing anything with them until I saw that they can be controlled using an app called WLED which in turn can be integrated with Home Assistant (HA).  I think the W in WLED stands for wifi; LEDs are connected to an ESP8266 which controls them and the WLED iPAD app allows you to configure patterns.

Arduino Setup

My first task was to setup an ESP8266 and connect the LED strip.  I used an article by mechatronics to guide me, it shows the connections are very simple.




I then loaded the example sketch, which uses the FastLED library, into ESP8266 and it works, without modification, displaying an attractive red / blue pattern on the LEDs .  Always a pleasant surprise when this happens😊

The sketch shows that displaying a pattern is simply a matter of putting correct colour values in the array leds[] and calling FastLED.show to display them.  They pattern can be made to change by adding loop to the sketch specifying how the pattern changes each time.  It gives me complete control of which LEDs are are used, what colours they are and when they change from a C program😊

WLED Install

WLED runs on an ESP8266 to control the strip.  It has a ultra-cool website URL kno.wled.ge  which provides the relevant installation instructions.  WLED is loaded into the ESP8266 using a utility esptool.py.  I downloaded esptool.py and WLED 0.13.1 to WSL then ran esptool.py to flash WLED onto the ESP8266.   ESP8266 starts up with an access point WLED-AP.  I attach to WLED-AP and go to address 4.3.2.1 in my browser to connect to the ESP program.

Now all I have to do is configure my Wifi network and password, then restart and I can access the browser app from any local network browser😊

WLED is surprisingly complicated to use; there are over 100 effects you can use to create LED patterns and a variety of colour palettes you can choose.  You can set the speed, select groups of LEDs and string a sequence of patterns together.  


Luckily there are various youtube tutorials to help you and kno.wled.ge provides a list.  I used a couple of tutorials by Dr zzs to give me the general idea.

WLED API

I dont find it easy to setup devices based on a graphical user interface, it is too easy to forget/overlook details.  WLED provides both HTTP and JSON APIs allowing you to control WLED remotely.  JSON is the newer, more complete interface which is easier to code / read so I concentrated on setting up some JSON configs.  Curl is used to send WLED API commands, as a simple example the following command turns the LED strip on.


In practice it is better to put the json into a file, the example below causes WLED to blink LEDs 30 to 40 in the strip between blue and green.
Now that I have a mechanism to program WLED I can create a variety of configs for the lights.  WLED allows you to setup presets to store configurations; once I have downloaded a configuration I save it in a preset.

HA and GA

There is a HA native integration for WLED making it trivial to include it within the system.  HA allows you to control individual elements, however I think it is easier to setup presets as shown above then invoke them within HA.



Now WLED can be controlled by running a HA script and I can set up a routing in Google Home for voice control of LEDs, job done😊