Start a new topic

Simple Text Editor Program

So I've been working on this little module for my Nextion 4,3'' project which is a small text editor: it's got 3 keyboards (Latin, National and Numeric) and a cursor. It can easily be imported into any existing project you may have.

I wanted to share it on the free chat for a couple reasons: firstly, someone might find this a helpful addition to their projects but, secondly, and more importantly, others might suggest much better ideas and improvements on the style, key images, code, algorithm, etc. which I'll be glad to consider and implement.

I've also included a .zi file for a slightly polished default Consolas font which was initially too bold for my liking.

And if any explanations for the code become necessary, I'll be happy to provide them.

(7.91 KB)
(346 KB)

Thanks Andrew

Two tricks to consider for the future

 - reduction into a single page

 - created as an importable *.page

Question on encodings

   HMI was encoded iso-8859-1 and zi iso-8859-5

   by design? 

Question is that I don't know if there is loss of function

   when encoded both to iso-8859-5 or if there was an

   advantage you discovered doing in this manner.

Changing the HMI encoding to iso-8859-5 and back to iso-8859-1

   changed the Nextion Editor Press/Release code in buttons ...

KEYRUS: b9 and b8 same letter?  same code for both.

Not sure what all the reqional issues maybe ...

I will add this to the Tools, Tips, Tricks and HowTos.  =)

As far as any suggestions for style improvements ...

One technique I have seen is to use full screen graphic as page background

 - with a picture resource off all buttons up and

 - another picture resource of all buttons when pressed

A component can then use cropping

 - in press event changing .picc to  the down picture resource

   and in release changing it back to the up picture resource

In this type of manner, you end up with full control over look and style.

It may increase HMI size, but you're hardly denting your available 32MB =)

Only thing is, I'm not Andrew. My name is Cyril and I'm his son :)

About the encodings: that is a blunder on my inexperienced part. Somehow, I managed to upload a buggy version where the encodings were indeed messed up until I corrected them later. This version also had a faulty SPACEBAR on the KEYRUS page. I've enclosed the correct file.

The b9 and b8 letters are in fact different: one of them has a little tail :)

I'd better sign the posts I make here in order to avoid misunderstandings.

(346 KB)

Well Cyril, the new one works much nicer.

(in blundered HMI had b8 and b9 the same code, you've since fixed)

You would also be welcome to have your own profile here as well.

On the subject of overlapping two images of pressed and unpressed keyboards, we did try that technique but the difference in size put us off. It is relatively small compared to 32MB but it was six times as large as this simpler version.

Hi again Patrick!

As you suggested, I went ahead and did the sensible thing by creating my own account :)

As I was thinking about other small gimmicks to add to this keyboard, I wondered whether it was possible to add a feature where a symbol is typed continuously when you hold a key down (gradually speeding up).

Doing this without the acceleration is straightforward with the help of a timer, but I'd like to take it a step further.

So I set up a simple test with a text window and had my timer decrease its .tim property (which is mutable). This worked... kinda. The .tim property can't be less than a certain safe value. I'm assuming this is so that it can have time to execute its code before being woken once again, so if my timer code takes, say, 10ms to complete, then I can't decrement .tim past that boundary? Or is there a slightly different rule at play? Are there any guidelines you can suggest when fiddling with timer values?

many ways lead to Roma ...

a standard PC keyboard timer ticks with 18.2 counts per sec. ... so, the Nextion timer with a minimum of 50 ms has 20 ticks per sec ...pretty good ...

I wouldn't change the timer ticks itself ... but use a small delay inside the timer loop which also interrupts the timer ...

(8.55 KB)

Ah, I see! There is a 'delay' system variable! That solves the whole problem of shortening the interval! Thanks, Gerry! I can see Rome on the horizon now :)

Remember that delay is a "Halt in place and do nothing" command

And that timer intervals only start when the code in timer ends.

Multiple timers can create interesting effects

   everything is still sequentially processed

So during the past couple of days, I've made a 7-inch version of the editor and improved the design (colors, layout...).

Thanks to the additional space on the 7'' display, I've added a HOME and an END key which allow you to jump to the start and end of a string respectively. In addition, there is now a counter which shows how many symbols you're allowed to type and how many you have available.

These additional gimmicks won't fit into the 4.3 inch display so that one has remained largely unchanged, apart from some minor changes in the pre-initialization code.

If anyone has any better, more visually appealing key images (such as the arrow keys, ENTER, BACKSPACE, CAPSLOCK...), then I'll be thankful if you could share them.

(351 KB)


What might be possible for 4.3" is to do something like this

functions to swap keys out on caplock (text component on background)

This was made for the 3.5" so the height is 48 pixels more high.
but might leave enough editing space on the 4.3"

Functionally, more stylus friendly than finger friendly.

Login or Signup to post a comment