diff --git a/scripts/pico_project.py b/scripts/pico_project.py index 3af4d22..09a95f8 100644 --- a/scripts/pico_project.py +++ b/scripts/pico_project.py @@ -109,6 +109,20 @@ def GDB_NAME(): "// Set datasheet for more information on function select", "gpio_set_function(UART_TX_PIN, GPIO_FUNC_UART);", "gpio_set_function(UART_RX_PIN, GPIO_FUNC_UART);", + "", + "// Use some the various UART functions to send out data", + "// In a default system, printf will also output via the default UART", + "", + # here should be following + # "// Send out a character without any conversions", + #"uart_putc_raw(UART_ID, 'A');", + #"", + #"// Send out a character but do CR/LF conversions", + #"uart_putc(UART_ID, 'B');", + # "", + "// Send out a string, with CR/LF conversions", + "uart_puts(UART_ID, \" Hello, UART!\\n\");", + "", "// For more examples of UART use see https://github.com/raspberrypi/pico-examples/tree/master/uart" ) ], @@ -438,6 +452,7 @@ def ParseCommandLine(): parser.add_argument("-t", "--tsv", help="Select an alternative pico_configs.tsv file", default=GetFilePath("pico_configs.tsv")) parser.add_argument("-o", "--output", help="Set an alternative CMakeList.txt filename", default="CMakeLists.txt") parser.add_argument("-x", "--examples", action='store_true', help="Add example code for the Pico standard library") + parser.add_argument("-ux", "--uartExample", action='store_true', help="Add example code for UART support with the Pico SDK") parser.add_argument("-l", "--list", action='store_true', help="List available features") parser.add_argument("-c", "--configs", action='store_true', help="List available project configuration items") parser.add_argument("-f", "--feature", action='append', help="Add feature to generated project") @@ -1137,11 +1152,16 @@ def DoEverything(parent, params): if params['features']: features_and_examples = params['features'][:] else: - features_and_examples= [] + features_and_examples = [] if params['wantExamples']: features_and_examples = list(stdlib_examples_list.keys()) + features_and_examples + if params['wantUARTExample']: + # add uart to features_and_examples if not present + if "uart" not in features_and_examples: + features_and_examples.append("uart") + if not (params['wantConvert']): GenerateMain(projectPath, params['projectName'], features_and_examples, params['wantCPP'], params['wantEntryProjName']) @@ -1326,6 +1346,7 @@ def DoEverything(parent, params): 'wantRunFromRAM': args.runFromRAM, 'wantEntryProjName': args.entryProjName, 'wantExamples' : args.examples, + 'wantUARTExample': args.uartExample, 'wantUART' : args.uart, 'wantUSB' : args.usb, 'wantCPP' : args.cpp, diff --git a/src/webview/newProjectPanel.mts b/src/webview/newProjectPanel.mts index 27968e2..6bc11f7 100644 --- a/src/webview/newProjectPanel.mts +++ b/src/webview/newProjectPanel.mts @@ -111,6 +111,7 @@ interface SubmitMessageValue extends ImportProjectMessageValue { picoWireless: number; // code generation options + addUartExample: boolean; runFromRAM: boolean; entryPointProjectName: boolean; cpp: boolean; @@ -154,6 +155,7 @@ enum PicoWirelessOption { } enum CodeOption { + addUartExample = "Add UART example code", runFromRAM = "Run the program from RAM rather than flash", entryPointProjectName = "Use project name as entry point file name", cpp = "Generate C++ code", @@ -231,6 +233,8 @@ function enumToParam( return "-f picow_poll"; case PicoWirelessOption.picoWBackground: return "-f picow_background"; + case CodeOption.addUartExample: + return "-ux"; case CodeOption.runFromRAM: return "-r"; case CodeOption.entryPointProjectName: @@ -1093,6 +1097,7 @@ export class NewProjectPanel { : null, ].filter(option => option !== null) as Library[], codeOptions: [ + theData.addUartExample ? CodeOption.addUartExample : null, theData.runFromRAM ? CodeOption.runFromRAM : null, theData.entryPointProjectName ? CodeOption.entryPointProjectName @@ -1836,6 +1841,20 @@ export class NewProjectPanel { +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • + + @@ -1864,20 +1883,14 @@ export class NewProjectPanel {
  • - - -
    -
  • -
  • -
    - - + +
  • - - + +
  • diff --git a/web/main.js b/web/main.js index 7b723a9..d0fa25b 100644 --- a/web/main.js +++ b/web/main.js @@ -334,6 +334,7 @@ var exampleSupportedBoards = []; const pioFeature = document.getElementById('pio-features-cblist').checked; const i2cFeature = document.getElementById('i2c-features-cblist').checked; const dmaFeature = document.getElementById('dma-features-cblist').checked; + const uartFeature = document.getElementById('uart-example-features-cblist').checked; const hwwatchdogFeature = document.getElementById('hwwatchdog-features-cblist').checked; const hwclocksFeature = document.getElementById('hwclocks-features-cblist').checked; const hwinterpolationFeature = document.getElementById('hwinterpolation-features-cblist').checked; @@ -389,6 +390,7 @@ var exampleSupportedBoards = []; pioFeature: pioFeature, i2cFeature: i2cFeature, dmaFeature: dmaFeature, + addUartExample: uartFeature, hwwatchdogFeature: hwwatchdogFeature, hwclocksFeature: hwclocksFeature, hwinterpolationFeature: hwinterpolationFeature,