Documentation ¶
Overview ¶
Package de2gui contains code for providing a graphical facsimile of the Terasic DE2-115 development board.
Index ¶
- Variables
- type UIState
- func (s *UIState) ClearFutures()
- func (s *UIState) ClearKEY()
- func (s *UIState) ClearSW()
- func (s *UIState) FyneObject() fyne.CanvasObject
- func (s *UIState) KEY() uint32
- func (s *UIState) SW() uint32
- func (s *UIState) ScheduleFuture(when uint64, f func(*UIState))
- func (s *UIState) SetHEX(i int, state uint8)
- func (s *UIState) SetLEDG(state uint32)
- func (s *UIState) SetLEDR(state uint32)
Constants ¶
This section is empty.
Variables ¶
var ColorGreenActive color.RGBA = color.RGBA{25, 200, 25, 255}
ColorGreenActive is the color used for green-colored illuminated parts when they are active.
var ColorGreenInactive color.RGBA = color.RGBA{15, 25, 15, 64}
ColorGreenInactive is the color used for green-colored illuminated parts when they are not active.
var ColorRedActive color.RGBA = color.RGBA{200, 25, 25, 255}
ColorRedActive is the color used for red-colored illuminated parts when they are active.
var ColorRedInactive color.RGBA = color.RGBA{25, 15, 15, 64}
ColorRedInactive is the color used for red-colored illuminated parts when they are not active.
var KeyPushMaxTime uint64 = 250
KeyPushMaxTime is the maximum number of ticks until a key is released after it is pushed
var KeyPushMinTime uint64 = 10
KeyPushMinTime is the minimum number of ticks until a key is released after it is pushed
Functions ¶
This section is empty.
Types ¶
type UIState ¶
type UIState struct { // The Tick value is displayed to the user as the current tick #, and // is also used to determine when to run futures Tick uint64 // OnKEY is run when any key is changed (pressed or released) OnKEY func(*UIState) // OnSW is run with any SW is changed OnSW func(*UIState) // OnTick is run when any of the tick-related controls is used. // // The boolean parameter is used as a performance optimization, it will // be true if and only if this it the final tick in a range of many // ticks which occur at once. For example, it might be best to call // functions like SetHex() only when this parameter is true, to avoid // spurious UI updates. OnTick func(*UIState, bool) // OnReset is run when the reset button is used OnReset func(*UIState) // contains filtered or unexported fields }
UIState contains all of the GUI widgets, and the data needed to interact with them.
The UI revolves around the assumption that the underlying simulation runs in discrete simulation "ticks". The OnTick callback is called whenever the user does something that triggers one or more ticks to occur. The downstream GUI is expected to update the Tick field appropriately when they handle simulation ticks.
Certain aspects of the UI also deal with events happening in the "future". Namely, when a KEY is pressed, it stays "pressed" for a variable number of ticks (this is to simulate real hardware, where a button will be pressed by a human for many thousands of clock cycles). This is handled by scheduling a key release for the future. Futures run when the Tick field equals their scheduled time to run and a Tick occurs. Futures run before OnTick is called.
func NewUIState ¶
func NewUIState() *UIState
NewUIState initializes a new instance of the DE2GUI's state object along with all of the needed widgets. After calling this, FyneObject() can safely be called.
EtraWidgets, if non-nil, will be inserted into the left panel of the created GUI elements.
func (*UIState) ClearFutures ¶
func (s *UIState) ClearFutures()
ClearFutures removes all functions scheduled to run in the future. You almost certainly want to call this in your OnRest() method.
func (*UIState) ClearKEY ¶
func (s *UIState) ClearKEY()
ClearKEY "un-presses" all KEYs. If you have called ClearFutures, you probably want to call this also, since the futures that would have released any pressed keys will now be deleted.
func (*UIState) ClearSW ¶
func (s *UIState) ClearSW()
ClearSW resets all switches to the "off" state. You might want to call this in your OnRest() method.
func (*UIState) FyneObject ¶
func (s *UIState) FyneObject() fyne.CanvasObject
FyneObject will return a Fyne canvas object which contains all of the widgets and such relating to this instance of the UIState. This should be suitable for use with Window.SetContent. However for more advanced use cases, it can be embedded in a container as needed.
func (*UIState) KEY ¶
KEY returns the current value of the KEY controls. There are 4 keys. The rightmost key is the least-significant bit. Unused higher order bits are left as zero.
func (*UIState) SW ¶
SW gets the current value of the SW(itch) controls. There are 18 switches. The rightmost switch is assigned to the least-significant bit. Unused higher order bits are left as zero.
func (*UIState) ScheduleFuture ¶
ScheduleFuture will cause the provided callback to be executed whenever a tick occurs and s.Tick is at least equal to `when`.
func (*UIState) SetHEX ¶
SetHEX updates the state of the i-th HEX display. Hex display 0 is the rightmost (least significant)
0 ----- | | 5 | | 1 | 6 | ----- | | 4 | | 2 | 3 | -----
Segments are packed into a uint8 as shown in the above diagram. Segments are active-low.
Directories ¶
Path | Synopsis |
---|---|
widgets
|
|
hexwidget
Package hexwidget implements a 7-segment style hexadecimal display
|
Package hexwidget implements a 7-segment style hexadecimal display |
ledwidget
Package ledwidget defines a GIU widget that mimics the appearance of the DE2-115 LED groups.
|
Package ledwidget defines a GIU widget that mimics the appearance of the DE2-115 LED groups. |