Matrix Keypad routine


Results 1 to 40 of 135

Threaded View

  1. #11
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post

    I think what I'm really trying to say here is that, if we want (a) to equal 100, and we can predict this value, then why use a formula? (It's unnecessary maths)

    Code:
    Public Function DrawLCD()
       '-----------------------------------------------------------------------------
       '// 2 Line 16 LCD_Chrs 5x7 matrix                                            '
       '-----------------------------------------------------------------------------
       Dim i As Long 'General working var for nested loops
       Dim j As Long '^
       Dim k As Long '^
       Dim f As Long '^
       Dim e As Long '^
       Dim h As Long '^
       
       '// Draw display matrix with all segs off    '
       For LCD_Row = 0 To 1                         '2 lines
           For LCD_Chrs = 0 To 15                   '16 chrs per line
               For f = 0 To 7                       'Matrix row
                   For k = 0 To 4                   'Matrix col
                       For j = 0 To Draw_Scale - 1  'Ea seg is (dscale x dscale) pixels
                           For i = 0 To Draw_Scale - 1 '^
                               SetPixelV LCD.hdc, 2 + i + k * (Draw_Scale + 1) + (LCD_Chrs * Draw_Scale * 6) + (LCD_Chrs * 4), 3 + j + (f * (Draw_Scale + 1)) + (LCD_Row * Draw_Scale * 9) + LCD_Row * 7, vbGreen
                           Next
                       Next
                   Next
               Next
           Next
       Next
    I'm forced into using calculations with the above code because we can't easily predict the values of the variables without making things even more complex than they already are. So there's plenty of valid reasoning behind this predicate arrangement. But if we can predict what we want, and it's feasible to do so, why not hard code it???
    <hr/>
    Last edited by T.Jackson; - 23rd May 2007 at 14:57.

Similar Threads

  1. calculator-like code entry with matrix keypad and display
    By Dennis in forum mel PIC BASIC Pro
    Replies: 35
    Last Post: - 16th December 2009, 22:58
  2. Need help in matrix keypad coding
    By rano_zen06 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 24th May 2008, 13:16
  3. I2C PCF8574 4X4 Keypad routine
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th January 2007, 21:25
  4. Inconsistent output on a 4x4 matrix keypad
    By markcadcam in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 24th November 2006, 03:54
  5. very basic matrix keypad question
    By kitcat in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th July 2006, 21:33

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts