Shop OBEX P1 Docs P2 Docs Learn Events
A couple of comments about the learning C course that Andy is creating — Parallax Forums

A couple of comments about the learning C course that Andy is creating

4x5n4x5n Posts: 745
edited 2013-05-29 14:34 in Learn with BlocklyProp
Actually it's currently one comment and one question. :cool:

The first is that when going through the exercise using pushbuttons for input it was mentioned that the programs wouldn't work with the resistive inputs on the quickstart board. Any one know the reason why?

The second has to do with a "parts kit" for the learning C course. Are there plans to provide one? I know that parallax sells "parts kits" for things like the PEK, etc. I think it would be helpful for someone that doesn't have parts bins loaded with LEDs, pushbuttons, appropriate resistors, etc. Rather than have to go through all the tutorials and figure out what's needed I know I would rather buy them all at once in a single package. I understand the course isn't complete and it may be a bit early to provide such a parts kit but I hope one is being planned.

Comments

  • mindrobotsmindrobots Posts: 6,506
    edited 2013-05-21 13:58
    The Quickstart buttons aren't simple switches (set to input, read pin). You need to go through a couple steps to charge them and then read the input. There is C code floating around in the propgcc demos to do this but it hasn't been put into the simple library collection (yet?).
  • 4x5n4x5n Posts: 745
    edited 2013-05-21 14:56
    mindrobots wrote: »
    The Quickstart buttons aren't simple switches (set to input, read pin). You need to go through a couple steps to charge them and then read the input. There is C code floating around in the propgcc demos to do this but it hasn't been put into the simple library collection (yet?).

    That's interesting. Is the ina spin command doing something special that makes the inputs work?

    I ask because with the QS powered from the usb port I can take it with me for "on the go puttering" without having to bring a power supply, leds, pushbuttons, etc. Just need the QS board, laptop and usb cable to do a lot of coding. The small size is an added bonus. I'm going to have to look for the C code that makes the QS work with C. :smile:
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2013-05-21 15:20
    Thanks for answering Question 1, mindrobots.

    For Question 2, the answer is "We are working on it!" The parts used so far loosely follow the "What's a Microcontroller?" Parts Kit but it is likely we will be using a different combination for a starter kit.
  • Jen J.Jen J. Posts: 649
    edited 2013-05-21 15:21
    Moving this thread to the Learn forum. Thanks!
  • jazzedjazzed Posts: 11,803
    edited 2013-05-21 15:22
    Quickstart Button C code.
    https://code.google.com/p/propgcc/source/browse/demos/forumists/jazzed/QSwam/qswam.c
    Part of Quickstart Whack-a-mole demo, bottom of page.
    /*
     * Get a specific button number.
     * buttons are enumerated from 0 to 7.
     */
    int getButton(int n)
    {
        return (getButtons() & (1<<n));
    }
    
    
    /*
     * Get all buttons at once
     * Run this function from HUB if compiled for LMM.
     */
    int getButtons()
    {
        int n = 16;
        int result  = -1;
        int reading =  0;
        int pins = 0xFF;
        OUTA |= pins;               //output high to buttons
    
    
        while(n--)
        {
            DIRA |= pins;           //output high to buttons
            DIRA ^= pins;           //switch to input
            reading = pins;
            msleep(2);              //wait for RC time
            reading &= INA;          //return button states
            result  &= reading;
        }
        result = ~result & 0xFF;
        return result;
    }
    


    Quickstart Button Spin/PASM
    Reference http://www.parallaxsemiconductor.com/sites/default/files/parallax/TouchButtonsLEDDemov1.0_1.zip
    Touch Buttons.spin
    CON
    
      BUTTON_PINS   = $FF           ' The QuickStart's touch buttons are on the eight LSBs
      SAMPLES       = 32            ' Require 32 high redings to return true
    
    VAR
      
      long  Results
    
    PUB Start(Rate)
    
      Results := Rate
      cognew(@Entry, @Results)      ' Launch a new cog to read samples
    
    PUB State | Accumulator
    
      Accumulator := Results        ' Sample multiple times and return true
      repeat constant(SAMPLES - 1)  '  if every sample was highw
        Accumulator &= Results
      return Accumulator
    
    DAT
                            org
    Entry                                                                                                                                    
                  rdlong    WaitTime, par
                  mov       outa, #BUTTON_PINS              ' set TestPins high, but keep as inputs
    
    
                  mov       Wait, cnt                       ' preset the counter
                  add       Wait, WaitTime
    Loop
                  or        dira, #BUTTON_PINS              ' set TestPins as outputs (high)
                  andn      dira, #BUTTON_PINS              ' set TestPins as inputs (floating)
                  mov       Reading, #BUTTON_PINS           ' create a mask of applicable pins
                  waitcnt   Wait, WaitTime                  ' wait for the voltage to decay
                  andn      Reading, ina                    ' clear decayed pins from the mask
                  wrlong    Reading, par                    ' write the result to RAM
                  jmp       #Loop
    
    
    Reading       res       1
    WaitTime      res       1
    Wait          res       1
    
  • 4x5n4x5n Posts: 745
    edited 2013-05-21 15:59
    Thanks for the C code. I don't know how I missed the spin code for the QS board. I've been using the ina command in spin and never noticed a problem. Guess I've been lucky all this time!!
  • 4x5n4x5n Posts: 745
    edited 2013-05-21 16:06
    Jen, thanks for moving this to a more appropriate forum.

    Steph, I'm glad to hear that there will be a parts kit offered. As I mentioned in my OP I understand that the tutorials aren't even close to being finished yet and as a result it's way to early to put together such a "kit".
  • FredBlaisFredBlais Posts: 375
    edited 2013-05-22 11:09
    4x5n,

    I heard about the "learning C course" but did not know that it was available (beta?). Where did you take the document?
  • SRLMSRLM Posts: 5,045
    edited 2013-05-22 11:24
    FredBlais wrote: »
    4x5n,

    I heard about the "learning C course" but did not know that it was available (beta?). Where did you take the document?

    I think you're asking about where the Parallax Learn material is?

    http://learn.parallax.com/propellerc
  • 4x5n4x5n Posts: 745
    edited 2013-05-22 14:54
    SRLM,

    That's the site for the C learning course I was referring to. :smile:

    Aside from the occasional "hello world" type program to convince myself I still remember C I haven't done any programming in it for better then 15 years! I've been going through the K&R book and find what Andy has done for Parallax to be an excellent refresher!
  • IamretiredIamretired Posts: 56
    edited 2013-05-29 13:51
    I have been using the course and it is just what I need..

    Frequently I look for any new lessons: Can you indicate on the 'Propeller C Tutorials' page if lessons have been updated or if any new lessons are available?

    John
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2013-05-29 14:34
    Iamretired wrote: »
    I have been using the course and it is just what I need..

    Frequently I look for any new lessons: Can you indicate on the 'Propeller C Tutorials' page if lessons have been updated or if any new lessons are available?

    John

    Glad you are enjoying them! Yes, I will post prominent notices on many web pages when tutorials have been added or changed, or when the Learn Library folder has been updated. There have not been any new tutorials lately. The developers are working hard to make improvements to the underlying libraries.
Sign In or Register to comment.