Go Down

Topic: Scrolling Display £ symbol (Read 499 times) previous topic - next topic

BrianL

Jul 15, 2019, 07:45 pm Last Edit: Jul 19, 2019, 09:45 am by BrianL
Hi
Firstly, sorry if this is in the wrong area, Mods please move as necessary
Secondly, I'm the original total knob when it comes to writing or reading programmes. So no tech talk!
What is my problem (other than no t being IT literate).. Well, I have a 8 unit MD MAX72xx driven from a Arduino Uno and loaded from #include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>)
All works well but I cant get a UK £ sign.  (Pound symbol)
How is this achieved please - In very simple terms please.
BTW I have tried to read through the Tutorials but cant initially find anything that relates or that I can understand!!

hammy

I'm not sure what you are doing as your details are sketchy...

ASCII tables might give you a clue ?

groundFungus

I think that the characters available are dictated by the font that you are using.  Here is a page with information on using fonts with Parola.

Paul__B

OK, first things first.

You need to go and read the forum instructions so that you can go back and modify your original post (not re-post it) - using the "More -> Modify" option below the right hand corner of your post - to mark up your code as such using the "</>" icon in the posting window.  Just highlight each section of code (or output if you need to post that) from the IDE and click the icon.

In fact, the IDE has a "copy for forum" link to put these markings on a highlighted block for you so you then just paste it here in a posting window.  But even before doing that, don't forget to use the "Auto-Format" (Ctrl-T) option first to make it easy to read.  If you do not post it as "code" it can as you now see, be quite garbled and is always more difficult to read.

It is inappropriate to attach it as a ".ino" file unless it is clearly too long to include in the post proper.  People can usually see the mistakes directly and do not want to have to actually load it in their own IDE.  And that would also assume they are using a PC and have the IDE running on that PC.

Also tidy up your blank space.  Do use blank lines, but only between complete functional blocks.



The information you are seeking on how to put the pound symbol in the font is explained here but I agree it is not easy to follow.  Someone - even Marco himself - may pop in to explain if you are lucky.  The usual convention is to put the English Pound symbol in place of the octothorp "#".

Try replacing the font line numbered 35 in MD_MAX72xx_font.cpp
Code: [Select]
 5, 0x14, 0x7f, 0x14, 0x7f, 0x14,  // 35 - '#'

with
Code: [Select]
 5, 0x68, 0x7e, 0x49, 0x41, 0x22  // 35 - '£'

BrianL

#4
Jul 19, 2019, 09:48 am Last Edit: Jul 19, 2019, 11:44 am by BrianL
Sorry about the errors I'm learning (Slowly!)  I have removed the reply which contained the whole sketch.
I did post this message as a continuation of my first post, but its failed to get a reply, so I've moved it to a new Quick Reply following on from the last post.

I used the code line you suggested and removed the code for# and replaced all the code with your suggestion. Saved then uploaded the whole sketch.  The £ sign now appears in the scrolling display BUT it now has an A immediately before it??  e.g. Admission: A£ 5.00    I cant get rid of the preceding A.   Any further help would be welcomed.

Paul__B

Sorry about the errors I'm learning (Slowly!)  I have removed the reply which contained the whole sketch.
That was a very silly thing to do!  :smiley-eek:

I used the code line you suggested and removed the code for# and replaced all the code with your suggestion. Saved then uploaded the whole sketch.  The £ sign now appears in the scrolling display BUT it now has an A immediately before it??  e.g. Admission: A£ 5.00    I cant get rid of the preceding A.
I can only suppose you made a mistake in the edit.  Might have to recover the original font file and try again.  :smiley-roll:

(Where is Marco?  I am sure I got the pattern change correct!)

BrianL

#6
Jul 20, 2019, 12:00 pm Last Edit: Jul 20, 2019, 12:16 pm by BrianL Reason: Screen shot 3 image attached
I simply deleted the line numbered 35 which showed a # symbol at the end and copied and pasted your new line in. Saved it then the sketch containing the new line was uploaded to Arduino. When powered up the scrolling text displayed correctly and the £ sign was then present (In two places) but each has a preceding A immediately before the £.  See screen shot 3 attachment

A very silly thing to do?  It was stated in an earlier post that I shouldn't have pasted the sketch as I did??

Below is the sketch again..Hopefully inserted correctly using the </> icon.  Blank spaces are already there from the pre made sketch? You can view this by downloading it,  if its not already in the library.  I'm beginning to get very lost now Im a total novice and do not understand coding or basic or anything such like. I can follow step by step instructions but if they start getting technical then it may as a well be written in Mandarin!  This little project started as a simple task and seems now to be getting deeper and deeper in to coding alterations and errors being made!  It originally was a simple to build 8 segment LED display, connect to Arduino Uno, look for ready made sketch, download the lot to PC then load to Arduino and see the scrolling results!   (Ctrl-T takes me to a New Tab in Google Chrome?)

Code: [Select]
[code]
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>



// Use the Parola library to scroll text on the display
//
// Demonstrates the use of the scrolling function to display text received
// from the serial interface
//
// User can enter text on the serial monitor and this will display as a
// scrolling message on the display.
// Speed for the display is controlled by a pot on SPEED_IN analog in.
// Scrolling direction is controlled by a switch on DIRECTION_SET digital in.
// Invert ON/OFF is set by a switch on INVERT_SET digital in.
//
// UISwitch library can be found at https://github.com/MajicDesigns/MD_UISwitch
// MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
//

#include <MD_Parola.h>
#include <MD_MAX72XX.h>
#include <SPI.h>

// set to 1 if we are implementing the user interface pot, switch, etc
#define USE_UI_CONTROL 0

#if USE_UI_CONTROL
#include <MD_UISwitch.h>
#endif

// Turn on debug statements to the serial output
#define DEBUG 0

#if DEBUG
#define PRINT(s, x) { Serial.print(F(s)); Serial.print(x); }
#define PRINTS(x) Serial.print(F(x))
#define PRINTX(x) Serial.println(x, HEX)
#else
#define PRINT(s, x)
#define PRINTS(x)
#define PRINTX(x)
#endif

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::ICSTATION_HW
#define MAX_DEVICES 8
#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN    10

// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
//MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

// Scrolling parameters
#if USE_UI_CONTROL
const uint8_t SPEED_IN = A5;
const uint8_t DIRECTION_SET = 8;  // change the effect
const uint8_t INVERT_SET = 9;     // change the invert

const uint8_t SPEED_DEADBAND = 5;
#endif // USE_UI_CONTROL

uint8_t scrollSpeed =30;    // default frame delay value
textEffect_t scrollEffect = PA_SCROLL_LEFT;
textPosition_t scrollAlign = PA_LEFT;
uint16_t scrollPause = 000; // in milliseconds

// Global message buffers shared by Serial and Scrolling functions
#define BUF_SIZE 75
char curMessage[BUF_SIZE] = { ""};
char newMessage[BUF_SIZE] = { "FMRC Exhibition 2019 Admission : Adult £5.00  Child £3.00  Under 5's free" };
bool newMessageAvailable = true;

#if USE_UI_CONTROL

MD_UISwitch_Digital uiDirection(DIRECTION_SET);
MD_UISwitch_Digital uiInvert(INVERT_SET);

void doUI(void)
{
  // set the speed if it has changed
  {
    int16_t speed = map(analogRead(SPEED_IN), 0, 1023, 10, 150);

    if ((speed >= ((int16_t)P.getSpeed() + SPEED_DEADBAND)) ||
      (speed <= ((int16_t)P.getSpeed() - SPEED_DEADBAND)))
    {
      P.setSpeed(speed);
      scrollSpeed = speed;
      PRINT("\nChanged speed to ", P.getSpeed());
    }
  }

  if (uiDirection.read() == MD_UISwitch::KEY_PRESS) // SCROLL DIRECTION
  {
    PRINTS("\nChanging scroll direction");
    scrollEffect = (scrollEffect == PA_SCROLL_LEFT ? PA_SCROLL_RIGHT : PA_SCROLL_LEFT);
    P.setTextEffect(scrollEffect, scrollEffect);
    P.displayClear();
    P.displayReset();
  }

  if (uiInvert.read() == MD_UISwitch::KEY_PRESS)  // INVERT MODE
  {
    PRINTS("\nChanging invert mode");
    P.setInvert(!P.getInvert());
  }
}
#endif // USE_UI_CONTROL

void readSerial(void)
{
  static char *cp = newMessage;

  while (Serial.available())
  {
    *cp = (char)Serial.read();
    if ((*cp == '\n') || (cp - newMessage >= BUF_SIZE-2)) // end of message character or full buffer
    {
      *cp = '\0'; // end the string
      // restart the index for next filling spree and flag we have a message waiting
      cp = newMessage;
      newMessageAvailable = true;
    }
    else  // move char pointer to next position
      cp++;
  }
}

void setup()
{
  Serial.begin(57600);
  Serial.print("\n[Parola Scrolling Display]\nType a message for the scrolling display\nEnd message line with a newline");

#if USE_UI_CONTROL
  uiDirection.begin();
  uiInvert.begin();
  pinMode(SPEED_IN, INPUT);

  doUI();
#endif // USE_UI_CONTROL

  P.begin();
  P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
}

void loop()
{
#if USE_UI_CONTROL
  doUI();
#endif // USE_UI_CONTROL

  if (P.displayAnimate())
  {
    if (newMessageAvailable)
    {
      strcpy(curMessage, newMessage);
      newMessageAvailable = false;
    }
    P.displayReset();
  }
  readSerial();
}
[/code]


Now when I look at the MD_MAX72XX-font.cpp file   35 is the # see screen shot 1 below.  But further down the code and sitting at 163 is a £ entry ??  See screen shot 2   So now I'm even more confused!  :o


PaulRB

#7
Jul 20, 2019, 02:41 pm Last Edit: Jul 20, 2019, 02:42 pm by PaulRB
Faversham?
Furness?
Falkirk?




Paul__B

I simply deleted the line numbered 35 which showed a # symbol at the end and copied and pasted your new line in. Saved it then the sketch containing the new line was uploaded to Arduino. When powered up the scrolling text displayed correctly and the £ sign was then present (In two places) but each has a preceding A immediately before the £.  See screen shot 3 attachment

That is a very mangled display!  Just hold the reset button to take a picture!  OK, it is not an "A", so I wonder what it is?

Oh, silly me!  :smiley-eek:  You have inserted a UNICODE symbol into your sketch, which is two bytes!  To use the modified file, you must specify the pound as a simple "#".


Ctrl-T takes me to a New Tab in Google Chrome?
Ctrl-T in the Arduino IDE formats the sketch according to common "C" conventions, making it as readable as possible - at the expense of some neatness.

Now when I look at the MD_MAX72XX-font.cpp file   35 is the # see screen shot 1 below.  But further down the code and sitting at 163 is a £ entry ??  See screen shot 2   So now I'm even more confused!  :o
So it was unnecessary.  You appear to have a different font file to mine - in mine, "Pounds" does appear as character 156 and most of the non-ASCII set is different.  In fact, mine is almost but not quite standard IBMSCII while yours corresponds to a different code page!

Given this, I would advise restoring the original file if you can (since I gave you the original pattern for character 35) and you will see what happens then.  The pound symbol is already there; you just have to specify it.  I was getting excessively bold (or trying to make it too easy to write the characters).

ASCII tables might give you a clue ?
Yes, the ASCII table!  :smiley-lol:

BrianL

#9
Jul 20, 2019, 04:42 pm Last Edit: Jul 20, 2019, 04:44 pm by BrianL




Oh, silly me!  :smiley-eek:  You have inserted a UNICODE symbol into your sketch, which is two bytes!  To use the modified file, you must specify the pound as a simple "#".


Ctrl-T in the Arduino IDE formats the sketch according to common "C" conventions, making it as readable as possible - at the expense of some neatness.
So it was unnecessary.  You appear to have a different font file to mine - in mine, "Pounds" does appear as character 156 and most of the non-ASCII set is different.  In fact, mine is almost but not quite standard IBMSCII while yours corresponds to a different code page!

Given this, I would advise restoring the original file if you can (since I gave you the original pattern for character 35) and you will see what happens then.  The pound symbol is already there; you just have to specify it.  I was getting excessively bold (or trying to make it too easy to write the characters).
Yes, the ASCII table:smiley-lol:
So this is where I come unstuck!... Unicode in my sketch?  Where is it?  Only thing I've altered AFAIK is the scrolling text to be displayed and the pause time at end of display to zero.

I can restore the file to original and save it.  How and where do I specify it? (The £ symbol) - Now that's where I started!  :-)

groundFungus

What text editor did you use to modify the file?  Maybe the editor does not work in ASCII text.  Use a program like Notepad that works only only with ASCII text?

Paul__B

No, it is not the editor used to modify the MD_MAX72XX-font.cpp file, but inserting a Unicode character into the strings specified in the IDE that generates the double character.  The "£" in the editor (as in this text) is two bytes.

If - using the modified file - you put "#" in your strings to be displayed, it will come out as "£".  Otherwise you have to put char(163) into the string.

BrianL

Thanks Paul__B, I will keep the .cpp file as original. 
But how and where exactly would I enter char(163) in the sketch??   I'm not at all conversant with alterations and how to do them. I am an absolute beginner with no basic or C understanding, so I need hand holding!!! 

Paul__B

Try
Code: [Select]
char newMessage[BUF_SIZE] = { "FMRC Exhibition 2019 Admission : Adult "+char(163)+"5.00  Child "+char(163)+"3.00  Under 5's free" };

BrianL

#14
Jul 21, 2019, 03:36 pm Last Edit: Jul 21, 2019, 04:27 pm by BrianL
With that replacing the original and when I run the 'Verify' command I get an error message (see screen shot below)....
Ironically if I insert a $ before 5.00 and 3.00   It works perfectly with the $ symbol showing correctly.
Code: [Select]
char newMessage[BUF_SIZE] = { "FMRC Exhibition 2019 Admission : Adult $5.00  Child $3.00  Under 5's free" };
  If I change the $ to £ it then reverts to the (looks like) A£. 
Without the £ or any other currency symbol it works correctly too. 
It has to be something to do with the £ ???

BTW  Note the Hardware is #define HARDWARE_TYPE MD_MAX72XX::ICSTATION_HW 
Not #define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW   as this when used causes the text to be upside down and scroll form the wrong end!   The ICSTATION_HW seems to work correctly (possibly?)

Go Up