Build Sudoku program using spare parts
Last year we had the Nextion (NX4827T043) used in the holiday light control project.
Using this same display I wanted to build a Sudoku puzzle program. Rather than using the GUI to build all the pieces and then just update the text on the screen I thought I would come at it a different way.
I first built a simple GUI interface that defined only three fonts that were of different sizes. From there I would build all the graphics using just the P1 and a custom Nextion library with basic functions for drawing lines and circles and filled rectangles.
Here is a sample of that screen generated by the P1:
Sudoku requires several matrixes and a lot of matrix logic to build this screen. In addition the program checks for bad answers in cells and rows. If it sees this, it highlights those numbers.
The program also looks for possible answers to a location and records them. For example if the only number left in a row or column is one of three numbers.
All this code is written in C so SimpleIDE is required to put this altogether.
The library makes use of the Full Duplex Object to capture screen event in the background. This allows picking numbers that you want to put in a location. Then the puzzle is redrawn to show the results.
At 9600 baud the screen updates take some time to happen and changing the default baud to something a little bit faster would be good.
To build the base puzzle I needed 9 squares by 9 squares. Using the 270 pixels and dividing by 9 you get 30 as the answer. This leaves 210 pixel to the right of the puzzle for other information such as the number to use and maybe hints.
The attached zip file contains the custom library with documentation along with the Sudoku puzzle program with a default puzzle.
I would like to add the hint function since all the code is already there just not displayed and disk support to allow loading puzzles from an SD card. This could be an issue since the disk support uses a lot of program space.