Shop OBEX P1 Docs P2 Docs Learn Events
Forum Request - How to do instructions for the forum — Parallax Forums

Forum Request - How to do instructions for the forum

Courtney,
Thank you very much for the How to PM instructions but could you also show how to post code, or anything else that is not intuitive.

Comments

  • Heater.Heater. Posts: 21,230
    Genetix,
    Any chance of your not posting with that extra large, bold and blocky font? Its very jarring. 
  • GenetixGenetix Posts: 1,754
    edited 2015-07-10 19:35
    Heater,
    Is this better?
  • Heater,
    Is this better?


    That's OK. Anything else, I have to put on my glasses. :)
    I miss the old Parallax Dark Theme. I could read the small print on a dark background.
  • mindrobotsmindrobots Posts: 6,506
    edited 2015-07-10 20:24
    Genetix,

    I think the current way to post code is using the HTML preformatted tags

    Let's see if it works:

    <pre>


    p, li { white-space: pre-wrap; }

    /*

    Blink Light.c



    Blink light circuit connected to P26.



    http://learn.parallax.com/propeller-c-simple-circuits/blink-light

    */




    #include "simpletools.h" // Include simpletools




    int main() // main function

    {

    while(1) // Endless loop

    {

    high(18);

    pause(100);

    high(17); // Set P17 I/O pin high

    pause(100); // Wait 1/10 second

    low(17); // Set P17 I/O pin low

    pause(100);

    low(18);

    pause(100); // Wait another 1/10 second

    }

    }

    </pre>


    ***EDIT***



    Yeah, not so much. The forum seems to want to insert some of its own text.



    Here's the text without any wrappers cut straight from SimpleIDE:






    p, li { white-space: pre-wrap; }

    /*

    Blink Light.c



    Blink light circuit connected to P26.



    http://learn.parallax.com/propeller-c-simple-circuits/blink-light

    */




    #include "simpletools.h" // Include simpletools




    int main() // main function

    {

    while(1) // Endless loop

    {

    high(18);

    pause(100);

    high(17); // Set P26 I/O pin high

    pause(100); // Wait 1/10 second

    low(17); // Set P26 I/O pin low

    pause(100);

    low(18);

    pause(100); // Wait another 1/10 second

    }

    }



    This is one of there work items - hopefully high on the list so we can share code snippets.

  • twm47099twm47099 Posts: 867
    edited 2015-07-11 14:22



    p, li { white-space: pre-wrap; }
    
    /*
    
    Blink Light.c
    
    Blink light circuit connected to P26.
    
    http://learn.parallax.com/propeller-c-simple-circuits/blink-light
    
    */
    
    
    #include "simpletools.h" // Include simpletools
    
    
    int main() // main function
    
    {
    
    while(1) // Endless loop
    
    {
    
    high(18);
    
    pause(100);
    
    high(17); // Set P17 I/O pin high
    
    pause(100); // Wait 1/10 second
    
    low(17); // Set P17 I/O pin low
    
    pause(100);
    
    low(18);
    
    pause(100); // Wait another 1/10 second
    
    }
    
    }
    
    
    


    [/code]
  • Heater.Heater. Posts: 21,230
    edited 2015-07-11 14:28
    You need to hit the "show source" icon before typing in the pre tag. Last button on the right with <> on it in red.
    int main(int argc, char* argv[]
    {
        printf("Hellow world
    ");
    }
    
  • twm47099twm47099 Posts: 867
    edited 2015-07-11 14:35
    Well I tried in the above post, but I made 2 mistakes -
    1.  I tried using my tablet, but it's editing, selecting, and copying "features" make it almost impossible to work -- it wasn't much easier on the old forum, and

    2.  I copied the code from your previous post which had already lost all of its formatting.

    Here's another try using a desktop computer - a short version of a C-learning program for the Ping.



    /*
      Test Ping.c
    
      Test the PING))) sensor before using it to navigate with the ActivityBot.
    
      http://learn.parallax.com/activitybot
    
    */
    
    #include "simpletools.h"                      // Include simpletools header
    #include "ping.h"                             // Include ping header
    
    int distance;                                 // Declare distance variable
    
    int main()                                    // main function
    {
      while(1)                                    // Repeat indefinitely
      {
        distance = ping_cm(8);                    // Get cm distance from Ping)))
    
        print("%c distance = %d%c cm",            // Display distance
               HOME, distance, CLREOL);    
          
      distance = ping(8);
      print("
     echo time = %d%c us", distance, CLREOL);
    
        pause(200);                               // Wait 1/5 second
      }
    }
    
    

    If it works I explain what I did.


    OK, it worked.
    Here's what I did:

    I copied the formatted code I wanted. 
    I clicked on the <> icon at the right of the editing pane in the editing pane.
    I saw a bunch of <br> and other code with my text mixed in. 
    I moved the cursor to where I wanted to add the program code and pressed enter a couple of times to make some room.
    I entered "<" no space "pre" no space ">" a few carriage returns "<" no space "/pre" no space ">"
    I repositioned my cursor in an empty line between the pre's I had just entered and pasted the program code.

    Tom
  • PublisonPublison Posts: 12,366
    edited 2015-08-06 21:13
    
    
    
    '' ******************************************************************************
    '' * I2C Demo Propeller program                                                 *
    '' * James Burrows Oct 2007                                                     *
    '' * Version 2.1                                                                *
    '' *                                                                            *
    '' * Demos:  i2cObject                                                          *
    '' * Uses :  Mike Green's "basic_i2c_driver" with a couple of extra bits        *
    '' *                                                                            *
    '' * demo'ing:                                                                  *
    '' *    Si570 and EEPROM objects                                                *
    '' *                                                                            *
    '' *  Code modified by Richard Newstead, G3CWI, Feb 2012 to add Si570           *
    '' ******************************************************************************
    ''
    '' this object provides the PUBLIC functions:
    ''  -> Start
    ''
    '' this object provides the PRIVATE functions:
    ''  -> Si570_demo     - Read the registers
    ''  -> EEPROM_demo    - write and read back 10 locations in the EEPROM
    ''  -> i2cScan        - scan the bus. Show results.
    ''
    '' Revision History:
    ''  -> V2 - re-release
    ''          v2.1 = Slight update to i2cObject code (readLocation was ACKing instead of NAK'ing)
    ''
    ''
    '' this object uses the following sub OBJECTS:
    ''  -> basic_i2c_driver
    ''
    ''
    '' Part information:
    ''  -> Si570
    ''  http://www.silabs.com/Support%20Documents/TechnicalDocs/si570.pdf
    ''  http://g4oep.atspace.com/si570/si570.htm
    ''  Got ya note: HS_DIV = Bin -4, N1= Bin -1 (see G4OEP speadsheet)
    ''
    ''  -> 24LC256 (32kb) or 24LC512 (64kb) - see www.microchip.com
    ''
    ''                        4.7K                       3.3V         3.3V
    ''                    ???????????  3.3V      24LC256???    Si570???
    ''                    ? ?????????  3.3V        ? ?          ? ?
    ''                    ? ?                      ? ?          ? ?
    ''   Pin29/SDA ?????????????????????????????????????????????????
    ''                      ?                        ?            ?
    ''   Pin28/SCL ????????????????????????????????????????????????
    ''
    ''
    '' Instructions (brief):
    '' (1) - setup the propeller - see the Parallax Documentation (www.parallax.com/propeller)
    '' (2) - Use a 5mhz crystal on propeller X1 and X2
    '' (3) - Connect the SDA lines to Propeller Pin28, and SCL lines to Propeller Pin29
    ''       See diagram above for resistor placements.
    ''       Connect the Si570 and 24LC256 (EEPROM) devices
    ''                  - the demo will work if they are not all present!
    ''
    '' (4) - OPTIONAL: Update the i2c Address's for the i2c if you are not using their base address's.
    '' (5) - Connect a terminal to the programming pins and use hypertrm or similar to see the results!
    '' (6) - Run the app!
    ''
    ''
    '' Support:
    ''   I will support this on the Parallax propeller forum (username Javalin)
    ''   send me a PM when you post in case I dont see it!
    ''   Contact Richard G3CWI for questions on the Si570 part
    
    CON
    _clkmode      = xtal1 + pll16x
    _xinfreq      = 5_000_000
    _stack        = 50
    
    i2cSCL        = 28
    i2cSDA        = 29
    
    
    EEPROMAddr    = %1010_0000
    Si570Addr     = %1010_1010   'AA
    
    
    ' EEPROM data base address - i.e 32K (assumes a 64kb eeprom installed!!)
    EEPROM_Base     = $8000
    
    ' debug - USE onboard pins
    pcDebugRX       = 31
    pcDebugTX       = 30
    
    ' serial baud rates
    pcDebugBaud     = 115200
    
    VAR
    long  i2cAddress, i2cSlaveCounter
    
    OBJ
    i2cObject      : "basic_i2c_driver"
    
    debug          : "Debug_PC"
    
    
    pub Start
    ' start the PC debug object
    debug.startx(pcDebugRX,pcDebugTX,pcDebugBaud)
    
    ' setup i2cobject
    i2cObject.Initialize(i2cSCL)
    
    ' pause 5 seconds
    repeat 20
    debug.putc(".")
    waitcnt((clkfreq/6)+cnt)
    debug.putc(13)
    
    ' i2c state
    debug.strln(string("I2C Demo (v2)!"))
    
    'demo the i2c scan
    i2cScan
    waitcnt(clkfreq +cnt)
    
    repeat
    
    
    
    ' demo the EEPROM
    if i2cObject.devicePresent(i2cSCL,eepromAddr) == true
    debug.strln(string("EEPROM Present"))
    'EEPROM_Demo
    else
    debug.strln(string("EEPROM Missing"))
    waitcnt(clkfreq+cnt)
    
    ' demo the Si570 Oscillator
    if i2cObject.devicePresent(i2cSCL,Si570addr) == true
    debug.strln(string("Si570 Present"))
    Si570_Demo
    else
    debug.strln(string("Si570 Missing"))
    waitcnt(clkfreq+cnt)
    
    PRI EEPROM_Demo | eepromData, eepromLocation, ackbit
    ' demo the i2c Serial EEPROM (Microchip's 24LC512 (64kb))
    debug.strln(string("EEPROM DEMO"))
    
    ' ***** EEPROM read/Write example *****
    eepromLocation := EEPROM_Base
    eepromData := 0
    
    repeat 5
    ' write long
    eepromData += 100
    i2cObject.WriteLong(i2cSCL, EEPROMAddr, eepromLocation, eepromData)
    
    ' read long
    eepromData :=0
    eepromData := i2cObject.ReadLong(i2cSCL, EEPROMAddr, eepromLocation)
    
    ' debug
    debug.str(string("Read Location="))
    debug.decx(eepromLocation,5)
    debug.str(string(", data="))
    debug.decx(eepromData,5)
    debug.putc(13)
    
    ' next
    eepromLocation +=4
    
    ' slowit
    waitcnt(clkfreq/20 + cnt)
    
    ' done
    debug.strln(string("EEPROM demo done."))
    
    
    
    PRI Si570_Demo | Si570Data, Si570Location, ackbit
    ' demo the Si570
    
    debug.strln(string("Si570 DEMO"))
    
    ' ***** Si570 write/read example *****
    
    
    {Example: TX 144.050, N1=4 HS_DIV=9 RFEQ=45.37643. Note that each Si570
    has individual parameters}
    
    i2cObject.WriteLocation (i2cSCL, Si570Addr, 137, %00010000) 'freeze DCO
    i2cObject.WriteLocation (i2cSCL, Si570Addr, 7,    $a0)
    i2cObject.WriteLocation (i2cSCL, Si570Addr, 8,    $c2)
    i2cObject.WriteLocation (i2cSCL, Si570Addr, 9,    $d6)
    i2cObject.WriteLocation (i2cSCL, Si570Addr, 10,   $05)
    i2cObject.WriteLocation (i2cSCL, Si570Addr, 11,   $db)
    i2cObject.WriteLocation (i2cSCL, Si570Addr, 12,   $76)
    i2cObject.WriteLocation (i2cSCL, Si570Addr, 137,  %00000000) 'unfreeze DCO
    i2cObject.WriteLocation (i2cSCL, Si570Addr, 135,  %01000000) 'Update freq
    
    Si570Location := 7
    Si570Data := 0
    
    repeat 12
    Si570Data :=0
    Si570Data := i2cObject.ReadLocation(i2cSCL, Si570Addr, Si570Location)
    
    ' debug
    debug.str(string("Read Si570 Location="))
    debug.decx(Si570Location,3)
    debug.str(string(", data byte Hex="))
    debug.hex(Si570Data,2)
    debug.putc(13)
    
    ' next
    Si570Location +=1
    
    ' slowit
    waitcnt(clkfreq/10 + cnt)
    
    Si570Location := 135
    Si570Data := i2cObject.ReadLocation(i2cSCL, Si570Addr, Si570Location)
    debug.str(string("Read Si570 Location="))
    debug.decx(Si570Location,3)
    debug.str(string(", data byte Hex="))
    debug.hex(Si570Data,2)
    debug.putc(13)
    
    Si570Location := 137
    Si570Data := i2cObject.ReadLocation(i2cSCL, Si570Addr, Si570Location)
    debug.str(string("Read Si570 Location="))
    debug.decx(Si570Location,3)
    debug.str(string(", data byte Hex="))
    debug.hex(Si570Data,2)
    debug.putc(13)
    
    ' done
    debug.strln(string("Si570 demo done."))
    
    Repeat 'Wait here
    
    PRI i2cScan | value, ackbit
    ' Scan the I2C Bus and debug the LCD
    debug.strln(string("Scanning I2C Bus...."))
    
    ' initialize variables
    i2cSlaveCounter := 0
    
    ' i2c Scan - scans all the address's on the bus
    ' sends the address byte and listens for the device to ACK (hold the SDA low)
    repeat i2cAddress from 0 to 127
    
    value :=  i2cAddress << 1 | 0
    ackbit := i2cObject.devicePresent(i2cSCL,value)
    
    if ackbit==false
    'debug.str(string("NAK"))
    else
    ' show the scan
    debug.str(string("Scan Addr :  %"))
    debug.bin(value,8)
    debug.str(string(",  ACK"))
    
    ' the device has set the ACK bit
    i2cSlaveCounter ++
    waitcnt(clkfreq/20+cnt)
    
    debug.putc(13)
    
    ' slow the scan so we can read it.
    waitcnt(clkfreq/40 + cnt)
    
    ' update the counter
    debug.str(string("i2cScan found "))
    debug.dec(i2cSlaveCounter)
    debug.strln(string(" devices!"))
    
    
  • Never thought I'd miss
    
    as much as I do. We should really have state of the art or at least state of 2012 code editing in a forum that is 70% about programming!                        
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-07-11 20:10
    A scrolled code box like we had before would also be nice. And that yellow background really screams YELLOW! I actually like a yellowish background for code, but #FFFFE0 is easier on the eyes.
    -Phil
  • Heater,
    The small fonts are very hard to read on a desktop and the black on white is very straining on the eyes not to mention the fact that my laptop lowers the brightness when I am running off the battery. A bigger font is a lot easier to read but that Arial Black font is somewhat jarring especially considering that's the default size.


    To the rest of you,
    Telling me how to add code is fine and dandy but what about all the new people who come here?
    That's why I asked for a How to sticky.
    Is there anything else other than adding code that would be good to have a sticky for?
  • IT is working on adding BBCode support. Because they assure me they're close to a solution with it, I will not be adding a how-to on the current method of putting code into a post.

    For now, use the suggestions above or simply attach your code as a file.
  • ITS A DIFFERENT TOPIC ALTOGETHER? ITS ON POWER INVERTER, I NEED TO KNOW THE CRITERIA USED TO CALCULATE THE NUMBER OF PARALLELED MOSFET TRANSISTORS IN COMING OUT WITH THE REQUIRED POWER OUTPUT IN SINE WAVE INVERTERS? FOR INSTANTS ONE REQUIRES A 3KVA POWER OUTPUT IN A GIVEN INVERTER, WHAT CRITERIA IS USED TO CALCULATE THE NUMBER OF MOASFET TRANSISTORS TO DRIVE THE TRANSFOMER TO ACHIEVE THE REQUIRED WATTAGE OUTPUT?

    REGARDS

    BERNARD TENDENGU
Sign In or Register to comment.