Skip to content

Commit

Permalink
Added UART feature
Browse files Browse the repository at this point in the history
Signed-off-by: paulober <[email protected]>
  • Loading branch information
paulober committed Sep 10, 2024
1 parent 3126024 commit e3a178b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 15 deletions.
23 changes: 22 additions & 1 deletion scripts/pico_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
],
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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'])

Expand Down Expand Up @@ -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,
Expand Down
41 changes: 27 additions & 14 deletions src/webview/newProjectPanel.mts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ interface SubmitMessageValue extends ImportProjectMessageValue {
picoWireless: number;

// code generation options
addUartExample: boolean;
runFromRAM: boolean;
entryPointProjectName: boolean;
cpp: boolean;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1836,6 +1841,20 @@ export class NewProjectPanel {
<label for="spi-features-cblist" class="w-full py-3 ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">SPI</label>
</div>
</li>
<li class="w-full border-b border-gray-200 sm:border-b-0 sm:border-r dark:border-gray-600">
<div class="flex items-center pl-3">
<input id="i2c-features-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500">
<label for="i2c-features-cblist" class="w-full py-3 ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">I2C interface</label>
</div>
</li>
<li class="w-full dark:border-gray-600">
<div class="flex items-center pl-3">
<input id="uart-example-features-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500">
<label for="uart-example-features-cblist" class="w-full py-3 ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">UART</label>
</div>
</li>
</ul>
<ul class="mb-2 items-center w-full text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg sm:flex dark:bg-gray-700 dark:border-gray-600 dark:text-white">
<li class="w-full border-b border-gray-200 sm:border-b-0 sm:border-r dark:border-gray-600">
<div class="flex items-center pl-3">
<input id="pio-features-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500">
Expand All @@ -1844,14 +1863,14 @@ export class NewProjectPanel {
</li>
<li class="w-full border-b border-gray-200 sm:border-b-0 sm:border-r dark:border-gray-600">
<div class="flex items-center pl-3">
<input id="i2c-features-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500">
<label for="i2c-features-cblist" class="w-full py-3 ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">I2C interface</label>
<input id="dma-features-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500">
<label for="dma-features-cblist" class="w-full py-3 ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">DMA support</label>
</div>
</li>
<li class="w-full dark:border-gray-600">
<div class="flex items-center pl-3">
<input id="dma-features-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500">
<label for="dma-features-cblist" class="w-full py-3 ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">DMA support</label>
<input id="hwinterpolation-features-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500">
<label for="hwinterpolation-features-cblist" class="w-full py-3 ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">HW interpolation</label>
</div>
</li>
</ul>
Expand All @@ -1864,20 +1883,14 @@ export class NewProjectPanel {
</li>
<li class="w-full border-b border-gray-200 sm:border-b-0 sm:border-r dark:border-gray-600">
<div class="flex items-center pl-3">
<input id="hwclocks-features-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500">
<label for="hwclocks-features-cblist" class="w-full py-3 ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">HW clocks</label>
</div>
</li>
<li class="w-full border-b border-gray-200 sm:border-b-0 sm:border-r dark:border-gray-600">
<div class="flex items-center pl-3">
<input id="hwinterpolation-features-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500">
<label for="hwinterpolation-features-cblist" class="w-full py-3 ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">HW interpolation</label>
<input id="hwtimer-features-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500">
<label for="hwtimer-features-cblist" class="w-full py-3 ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">HW timer</label>
</div>
</li>
<li class="w-full dark:border-gray-600">
<div class="flex items-center pl-3">
<input id="hwtimer-features-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500">
<label for="hwtimer-features-cblist" class="w-full py-3 ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">HW timer</label>
<input id="hwclocks-features-cblist" type="checkbox" value="" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-700 dark:focus:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500">
<label for="hwclocks-features-cblist" class="w-full py-3 ml-2 text-sm font-medium text-gray-900 dark:text-gray-300">HW clocks</label>
</div>
</li>
</ul>
Expand Down
2 changes: 2 additions & 0 deletions web/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -389,6 +390,7 @@ var exampleSupportedBoards = [];
pioFeature: pioFeature,
i2cFeature: i2cFeature,
dmaFeature: dmaFeature,
addUartExample: uartFeature,
hwwatchdogFeature: hwwatchdogFeature,
hwclocksFeature: hwclocksFeature,
hwinterpolationFeature: hwinterpolationFeature,
Expand Down

0 comments on commit e3a178b

Please sign in to comment.