Coder Social home page Coder Social logo

arduinomenu's Introduction

ArduinoMenu

AVR generic menu/interactivity system

Easy to define menu system with sub-menus and associated function to call Works either over serial or with LCD + encoder


V2.0

main changes: - non-blocking menu main cycle - Menufields as menu prompts with associated value values can be: numeric withing range list of values toggled on click (for small lists) list of values selected as submenu (for longer lists) - PCINT now supports Mega/2560 and possibly others

notes: - encoder now needs begin() to be called on setup


example of menu definition (c++ macros)

//a submenu
MENU(ledMenu,"LED on pin 13",
	OP("LED On",ledOn),
	OP("LED Off",ledOff)
);

//field value toggle on click
TOGGLE(targetVar,trigModes,"Mode: ",
	VALUE("None",trigPoint::None),
	VALUE("On rise",trigPoint::onRise),
	VALUE("On fall",trigPoint::onFall),
	VALUE("Both",trigPoint::isIn)
);

//field value, click to browse, click to choose
CHOOSE(adc_prescale,sample_clock,"Sample clock",
	VALUE("/128",avrADC::clk_128,setADCClk),
	VALUE("/64",avrADC::clk_64,setADCClk),
	VALUE("/32",avrADC::clk_32,setADCClk),
	VALUE("/16",avrADC::clk_16,setADCClk),
	VALUE("/8",avrADC::clk_8,setADCClk),
	VALUE("/4",avrADC::clk_4,setADCClk),
	VALUE("/2",avrADC::clk_2,setADCClk)
);

//the main menu...
//Fields are numeric and show selected value. click to start change, click to fine tune, click to end
MENU(mainMenu,"Main menu",
	FIELD(frequency,"Freq","Hz",0,16000000,100,1,updateFreq),
	FIELD(dutty,"Duty","%",0,100,1,0,updateDutty),
	OP("Handler test",completeHandlerTest),
	SUBMENU(trigModes),
	SUBMENU(ledMenu)
);

syntax:

OP(name,function) name string to be shown as menu option prompt function to be called on click

FIELD(variable,name,units,min,max,step,tune,function)
	Holding and changing numeric values
	where:
		variable: holding the value (must be numeric or support comparison oprators)
		name: to use as prompt
		units: to be shown after value
		min,max: defining numeric value range
		step: increment/decrement when adjusting value
		tune: value to increment/decrement when fine tunning the value
		function: called on every value change

VALUE(text,value)
	holding possible FIELD values
	where:
		text: to be used as prompt
		value: to be passed when selected
	
TOGGLE(variable,id,name,
	VALUE(...),
	...,
	VALUE(...)
)
	Holding a value and a list of possible values to toggle on click
	this is ideal for On/Off Yes/No and other small list of values
	where:
		variable: holding the value
		id: of this element to be used with SUBMENU
		name: to be used as prompt
		
CHOOSE(variable,id,name,
	VALUE(...),
	...,
	VALUE(...)
)
	Holding a value and a list of possible values to select as a submenu
	this is ideal for longer lists of values
	where:
		variable: holding the value
		id: of this element to be used with SUBMENU
		name: to be used as prompt

SUBMENU(id)
	link in a submenu as option of the current one
	where:
		id: the submenu id

MENU(id,name,
	...
	OP(...),
	FIELD(...),
	SUBMENU(...),
	...
)
define menu structure
where:
	id: this menu id

Notes:

input is read from generic streams, included simple streams for encoders and keyboards
- provided encoder driver uses internal pull-ups and reverse logic

output to menuOut devices, included derivations to support serial, GFX and lcd

multiple stream packing for input to mix encoder stream with encoder keyboard (usually 1 or 2 keys)

more info at http://r-site.net?lang=en&at=//op%5B@id=%273090%27%5D

arduinomenu's People

Contributors

christophepersoz avatar neu-rah avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.