libraries / Mitov / Mitov_MaximLedControl_7SegmentText.hon commit Added link to project report (97a3ba0)
   1////////////////////////////////////////////////////////////////////////////////
   2//                                                                            //
   3//     This software is supplied under the terms of a license agreement or    //
   4//     nondisclosure agreement with Mitov Software and may not be copied      //
   5//     or disclosed except in accordance with the terms of that agreement.    //
   6//         Copyright(c) 2002-2016 Mitov Software. All Rights Reserved.        //
   7//                                                                            //
   8////////////////////////////////////////////////////////////////////////////////
   9
  10#ifndef _MITOV_MAXIM_LED_CONTROL_7SEGMENT_TEXT_h
  11#define _MITOV_MAXIM_LED_CONTROL_7SEGMENT_TEXT_h
  12
  13#include <Mitov.h>
  14#include <Mitov_Basic_SPI.h>
  15//#include <Mitov_7Segment_Common.h>
  16
  17namespace Mitov
  18{
  19        const static byte C_MaximText7Segments[] PROGMEM =
  20        {
  21                B10100000, // !
  22                B00100010, // "
  23                B00000000, // #
  24                B01011011, // $
  25                B00100101, // %
  26                B01111111, // &
  27                B00000010, // '
  28
  29                B01001110, // (
  30                B01111000, // )
  31                B01100011, // *
  32                B00110001, // +
  33                B00000100, // ,
  34                B00000001, // -
  35                B10000000, // .
  36                B00100101, // /
  37
  38                B01111110, // 0
  39                B00110000, // 1
  40                B01101101, // 2
  41                B01111001, // 3
  42                B00110011, // 4
  43                B01011011, // 5
  44                B01011111, // 6
  45                B01110000, // 7
  46
  47                B01111111, // 8
  48                B01111011, // 9
  49                B00000000, // :
  50                B00000000, // ;
  51                B00000000, // <
  52                B01000001, // =
  53                B00000000, // >
  54                B01100101, // ?
  55
  56                B01101111, // @
  57                B01110111, // A
  58                B00011111, // B
  59                B00001101, // C
  60                B00111101, // D
  61                B01001111, // E
  62                B01000111, // F
  63                B01011110, // G
  64
  65                B00110111, // H
  66                B00110000, // I
  67                B00111100, // J
  68                B00110111, // K ???
  69                B00001110, // L
  70                B00000000, // M ???
  71                B00010101, // N
  72                B01111110, // O
  73
  74                B01100111, // P
  75                B01111110, // Q
  76                B00000101, // R
  77                B01011011, // S
  78                B00001111, // T
  79                B00111110, // U
  80                B00111110, // V
  81                B00000000, // W ???
  82
  83                B00110111, // X
  84                B00110011, // Y
  85                B01101101, // Z
  86                B01001110, // [
  87                B00010011, // backslash
  88                B01111000, // ]
  89                B01100010, // ^
  90                B00001000, // _
  91
  92                B00100000, // `
  93                B01110111, // a
  94                B00011111, // b
  95                B00001101, // c
  96                B00111101, // d
  97                B01001111, // e
  98                B01000111, // f
  99                B01111011, // g
 100
 101                B00010111, // h
 102                B00010000, // i
 103                B00111100, // j
 104                B00110111, // k ???
 105                B00110000, // l
 106                B00000000, // m ???
 107                B00010101, // n
 108                B00011101, // o
 109
 110                B01100111, // P
 111                B01110011, // q
 112                B00000101, // r
 113                B01011011, // s
 114                B00001111, // t
 115                B00011100, // u
 116                B00011100, // v
 117                B00000000, // w ???
 118
 119                B00110111, // x
 120                B00110011, // y
 121                B01101101, // z
 122                B01001110, // {
 123                B00000110, // |
 124                B01111000, // }
 125                B00010011  // ~
 126        };
 127//---------------------------------------------------------------------------
 128        class MaximLedGroupTextDisplay7Segments : public MaximLedGroupTypedValueDisplay7Segments<String>
 129        {
 130                typedef Mitov::MaximLedGroupTypedValueDisplay7Segments<String> inherited;
 131
 132        protected:
 133                virtual byte GetSegmentsValue( int &ADigit )
 134                {
 135                        int ARealDigit = CountDigits - ADigit - 1;
 136                        if( ARealDigit >= FValue.length() )
 137                                return 0;
 138
 139                        byte AValue = FValue[ ARealDigit ];
 140
 141                        if( AValue <= ' ' )
 142                                return 0;
 143
 144                        if( AValue > 126 )
 145                                return 0;
 146
 147//                      byte AResult = C_MaximText7Segments[ AValue ];
 148                        byte AResult = pgm_read_byte_near( C_MaximText7Segments + AValue - ' ' - 1 );
 149                        if( AResult & 0x80 )
 150                                return AResult;
 151
 152                        if( ARealDigit + 1 >= FValue.length() )
 153                                return AResult;
 154
 155                        if( C_MaximText7Segments[ FValue[ ARealDigit + 1 ]] != '.' )
 156                                return AResult;
 157
 158                        ++ARealDigit;
 159                        AResult |= 0x80;
 160
 161                        return AResult;
 162                }
 163
 164        public:
 165                using inherited::inherited;
 166
 167        };
 168//---------------------------------------------------------------------------
 169}
 170
 171#endif