text,length,is_long_context,metric_val,label_metric "/* Feathers Copyright 2012-2021 Bowler Hat LLC. All Rights Reserved. This program is free software. You can redistribute and/or modify it in accordance with the terms of the accompanying license agreement. */ package feathers.controls.supportClasses { import feathers.controls.Scroller; import feathers.controls.Tree; import feathers.controls.renderers.ITreeItemRenderer; import feathers.core.FeathersControl; import feathers.core.IFeathersControl; import feathers.core.IValidating; import feathers.data.IHierarchicalCollection; import feathers.data.IListCollection; import feathers.events.FeathersEventType; import feathers.layout.ILayout; import feathers.layout.IVariableVirtualLayout; import feathers.layout.IVirtualLayout; import feathers.layout.LayoutBoundsResult; import feathers.layout.ViewPortBounds; import flash.errors.IllegalOperationError; import flash.geom.Point; import flash.utils.Dictionary; import starling.display.DisplayObject; import starling.events.Event; import starling.utils.Pool; /** * @private * Used internally by Tree. Not meant to be used on its own. * * @productversion Feathers 3.3.0 */ public class TreeDataViewPort extends FeathersControl implements IViewPort { private static const INVALIDATION_FLAG_ITEM_RENDERER_FACTORY:String = ""itemRendererFactory""; private static const HELPER_VECTOR:Vector. = new []; private static const LOCATION_HELPER_VECTOR:Vector. = new []; public function TreeDataViewPort() { super(); } private var _viewPortBounds:ViewPortBounds = new ViewPortBounds(); private var _layoutResult:LayoutBoundsResult = new LayoutBoundsResult(); private var _actualMinVisibleWidth:Number = 0; private var _explicitMinVisibleWidth:Number; public function get minVisibleWidth():Number { if(this._explicitMinVisibleWidth !== this._explicitMinVisibleWidth) //isNaN { return this._actualMinVisibleWidth; } return this._explicitMinVisibleWidth; } public function set minVisibleWidth(value:Number):void { if(this._explicitMinVisibleWidth == value) { return; } var valueIsNaN:Boolean = value !== value; //isNaN if(valueIsNaN && this._explicitMinVisibleWidth !== this._explicitMinVisibleWidth) //isNaN { return; } var oldValue:Number = this._explicitMinVisibleWidth; this._explicitMinVisibleWidth = value; if(valueIsNaN) { this._actualMinVisibleWidth = 0; this.invalidate(INVALIDATION_FLAG_SIZE); } else { this._actualMinVisibleWidth = value; if(this._explicitVisibleWidth !== this._explicitVisibleWidth && //isNaN (this._actualVisibleWidth < value || this._actualVisibleWidth == oldValue)) { //only invalidate if this change might affect the visibleWidth this.invalidate(INVALIDATION_FLAG_SIZE); } } } private var _maxVisibleWidth:Number = Number.POSITIVE_INFINITY; public function get maxVisibleWidth():Number { return this._maxVisibleWidth; } public function set maxVisibleWidth(value:Number):void { if(this._maxVisibleWidth == value) { return; } if(value !== value) //isNaN { throw new ArgumentError(""maxVisibleWidth cannot be NaN""); } var oldValue:Number = this._maxVisibleWidth; this._maxVisibleWidth = value; if(this._explicitVisibleWidth !== this._explicitVisibleWidth && //isNaN (this._actualVisibleWidth > value || this._actualVisibleWidth == oldValue)) { //only invalidate if this change might affect the visibleWidth this.invalidate(INVALIDATION_FLAG_SIZE); } } private var _actualVisibleWidth:Number = NaN; private var _explicitVisibleWidth:Number = NaN; public function get visibleWidth():Number { return this._actualVisibleWidth; } public function set visibleWidth(value:Number):void { if(this._explicitVisibleWidth == value || (value !== value && this._explicitVisibleWidth !== this._explicitVisibleWidth)) //isNaN { return; } this._explicitVisibleWidth = value; if(this._actualVisibleWidth != value) { this.invalidate(INVALIDATION_FLAG_SIZE); } } private var _actualMinVisibleHeight:Number = 0; private var _explicitMinVisibleHeight:Number; public function get minVisibleHeight():Number { if(this._explicitMinVisibleHeight !== this._explicitMinVisibleHeight) //isNaN { return this._actualMinVisibleHeight; } return this._explicitMinVisibleHeight; } public function set minVisibleHeight(value:Number):void { if(this._explicitMinVisibleHeight == value) { return; } var valueIsNaN:Boolean = value !== value; //isNaN if(valueIsNaN && this._explicitMinVisibleHeight !== this._explicitMinVisibleHeight) //isNaN { return; } var oldValue:Number = this._explicitMinVisibleHeight; this._explicitMinVisibleHeight = value; if(valueIsNaN) { this._actualMinVisibleHeight = 0; this.invalidate(INVALIDATION_FLAG_SIZE); } else { this._actualMinVisibleHeight = value; if(this._explicitVisibleHeight !== this._explicitVisibleHeight && //isNaN (this._actualVisibleHeight < value || this._actualVisibleHeight == oldValue)) { //only invalidate if this change might affect the visibleHeight this.invalidate(INVALIDATION_FLAG_SIZE); } } } private var _maxVisibleHeight:Number = Number.POSITIVE_INFINITY; public function get maxVisibleHeight():Number { return this._maxVisibleHeight; } public function set maxVisibleHeight(value:Number):void { if(this._maxVisibleHeight == value) { return; } if(value !== value) //isNaN { throw new ArgumentError(""maxVisibleHeight cannot be NaN""); } var oldValue:Number = this._maxVisibleHeight; this._maxVisibleHeight = value; if(this._explicitVisibleHeight !== this._explicitVisibleHeight && //isNaN (this._actualVisibleHeight > value || this._actualVisibleHeight == oldValue)) { //only invalidate if this change might affect the visibleHeight this.invalidate(INVALIDATION_FLAG_SIZE); } } private var _actualVisibleHeight:Number; private var _explicitVisibleHeight:Number = NaN; public function get visibleHeight():Number { return this._actualVisibleHeight; } public function set visibleHeight(value:Number):void { if(this._explicitVisibleHeight == value || (value !== value && this._explicitVisibleHeight !== this._explicitVisibleHeight)) //isNaN { return; } this._explicitVisibleHeight = value; if(this._actualVisibleHeight != value) { this.invalidate(INVALIDATION_FLAG_SIZE); } } protected var _contentX:Number = 0; public function get contentX():Number { return this._contentX; } protected var _contentY:Number = 0; public function get contentY():Number { return this._contentY; } public function get horizontalScrollStep():Number { var itemRenderer:DisplayObject = null; var virtualLayout:IVirtualLayout = this._layout as IVirtualLayout; if(virtualLayout === null || !virtualLayout.useVirtualLayout) { if(this._layoutItems.length > 0) { itemRenderer = this._layoutItems[0] as DisplayObject; } } if(itemRenderer === null) { itemRenderer = this._typicalItemRenderer as DisplayObject; } if(itemRenderer === null) { return 0; } var itemRendererWidth:Number = itemRenderer.width; var itemRendererHeight:Number = itemRenderer.height; if(itemRendererWidth < itemRendererHeight) { return itemRendererWidth; } return itemRendererHeight; } public function get verticalScrollStep():Number { var itemRenderer:DisplayObject = null; var virtualLayout:IVirtualLayout = this._layout as IVirtualLayout; if(virtualLayout === null || !virtualLayout.useVirtualLayout) { if(this._layoutItems.length > 0) { itemRenderer = this._layoutItems[0] as DisplayObject; } } if(itemRenderer === null) { itemRenderer = this._typicalItemRenderer as DisplayObject; } if(itemRenderer === null) { return 0; } var itemRendererWidth:Number = itemRenderer.width; var itemRendererHeight:Number = itemRenderer.height; if(itemRendererWidth < itemRendererHeight) { return itemRendererWidth; } return itemRendererHeight; } private var _owner:Tree = null; public function get owner():Tree { return this._owner; } public function set owner(value:Tree):void { this._owner = value; } private var _updateForDataReset:Boolean = false; private var _dataProvider:IHierarchicalCollection = null; public function get dataProvider():IHierarchicalCollection { return this._dataProvider; } public function set dataProvider(value:IHierarchicalCollection):void { if(this._dataProvider == value) { return; } if(this._dataProvider) { this._dataProvider.removeEventListener(Event.CHANGE, dataProvider_changeHandler); /*this._dataProvider.removeEventListener(CollectionEventType.RESET, dataProvider_resetHandler); this._dataProvider.removeEventListener(CollectionEventType.ADD_ITEM, dataProvider_addItemHandler); this._dataProvider.removeEventListener(CollectionEventType.REMOVE_ITEM, dataProvider_removeItemHandler); this._dataProvider.removeEventListener(CollectionEventType.REPLACE_ITEM, dataProvider_replaceItemHandler); this._dataProvider.removeEventListener(CollectionEventType.UPDATE_ITEM, dataProvider_updateItemHandler); this._dataProvider.removeEventListener(CollectionEventType.UPDATE_ALL, dataProvider_updateAllHandler);*/ } this._dataProvider = value; if(this._dataProvider) { this._dataProvider.addEventListener(Event.CHANGE, dataProvider_changeHandler); /*this._dataProvider.addEventListener(CollectionEventType.RESET, dataProvider_resetHandler); this._dataProvider.addEventListener(CollectionEventType.ADD_ITEM, dataProvider_addItemHandler); this._dataProvider.addEventListener(CollectionEventType.REMOVE_ITEM, dataProvider_removeItemHandler); this._dataProvider.addEventListener(CollectionEventType.REPLACE_ITEM, dataProvider_replaceItemHandler); this._dataProvider.addEventListener(CollectionEventType.UPDATE_ITEM, dataProvider_updateItemHandler); this._dataProvider.addEventListener(CollectionEventType.UPDATE_ALL, dataProvider_updateAllHandler);*/ } if(this._layout is IVariableVirtualLayout) { IVariableVirtualLayout(this._layout).resetVariableVirtualCache(); } this._updateForDataReset = true; this.invalidate(INVALIDATION_FLAG_DATA); } private var _ignoreLayoutChanges:Boolean = false; private var _ignoreRendererResizing:Boolean = false; private var _layout:ILayout = null; public function get layout():ILayout { return this._layout; } public function set layout(value:ILayout):void { if(this._layout == value) { return; } if(this._layout) { this._layout.removeEventListener(Event.CHANGE, layout_changeHandler); } this._layout = value; if(this._layout) { if(this._layout is IVariableVirtualLayout) { var variableVirtualLayout:IVariableVirtualLayout = IVariableVirtualLayout(this._layout); variableVirtualLayout.resetVariableVirtualCache(); } this._layout.addEventListener(Event.CHANGE, layout_changeHandler); } this.invalidate(INVALIDATION_FLAG_LAYOUT); } private var _horizontalScrollPosition:Number = 0; public function get horizontalScrollPosition():Number { return this._horizontalScrollPosition; } public function set horizontalScrollPosition(value:Number):void { if(this._horizontalScrollPosition == value) { return; } this._horizontalScrollPosition = value; this.invalidate(INVALIDATION_FLAG_SCROLL); } private var _verticalScrollPosition:Number = 0; public function get verticalScrollPosition():Number { return this._verticalScrollPosition; } public function set verticalScrollPosition(value:Number):void { if(this._verticalScrollPosition == value) { return; } this._verticalScrollPosition = value; this.invalidate(INVALIDATION_FLAG_SCROLL); } public function get requiresMeasurementOnScroll():Boolean { return this._layout.requiresLayoutOnScroll && (this._explicitVisibleWidth !== this._explicitVisibleWidth || //isNaN this._explicitVisibleHeight !== this._explicitVisibleHeight); //isNaN } private var _ignoreSelectionChanges:Boolean = false; private var _isSelectable:Boolean = true; public function get isSelectable():Boolean { return this._isSelectable; } public function set isSelectable(value:Boolean):void { if(this._isSelectable == value) { return; } this._isSelectable = value; if(!this._isSelectable) { this.selectedItem = null; } this.invalidate(INVALIDATION_FLAG_SELECTED); } private var _selectedItem:Object = null; public function get selectedItem():Object { return this._selectedItem; } public function set selectedItem(value:Object):void { if(this._selectedItem == value) { return; } this._selectedItem = value; this.invalidate(INVALIDATION_FLAG_SELECTED); this.dispatchEventWith(Event.CHANGE); } private var _typicalItem:Object = null; public function get typicalItem():Object { return this._typicalItem; } public function set typicalItem(value:Object):void { if(this._typicalItem == value) { return; } this._typicalItem = value; this.invalidate(INVALIDATION_FLAG_DATA); } private var _itemRendererType:Class; public function get itemRendererType():Class { return this._itemRendererType; } public function set itemRendererType(value:Class):void { if(this._itemRendererType == value) { return; } this._itemRendererType = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _itemRendererFactory:Function; public function get itemRendererFactory():Function { return this._itemRendererFactory; } public function set itemRendererFactory(value:Function):void { if(this._itemRendererFactory === value) { return; } this._itemRendererFactory = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _itemRendererFactories:Object; public function get itemRendererFactories():Object { return this._itemRendererFactories; } public function set itemRendererFactories(value:Object):void { if(this._itemRendererFactories === value) { return; } this._itemRendererFactories = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _factoryIDFunction:Function; public function get factoryIDFunction():Function { return this._factoryIDFunction; } public function set factoryIDFunction(value:Function):void { if(this._factoryIDFunction === value) { return; } this._factoryIDFunction = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _customItemRendererStyleName:String; public function get customItemRendererStyleName():String { return this._customItemRendererStyleName; } public function set customItemRendererStyleName(value:String):void { if(this._customItemRendererStyleName == value) { return; } this._customItemRendererStyleName = value; this.invalidate(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); } private var _openBranches:IListCollection; public function get openBranches():IListCollection { return this._openBranches; } public function set openBranches(value:IListCollection):void { if(this._openBranches == value) { return; } if(this._openBranches !== null) { this._openBranches.removeEventListener(Event.CHANGE, openBranches_changeHandler); } this._openBranches = value; if(this._openBranches !== null) { this._openBranches.addEventListener(Event.CHANGE, openBranches_changeHandler); } this.invalidate(INVALIDATION_FLAG_DATA); } private var _typicalItemIsInDataProvider:Boolean = false; private var _typicalItemRenderer:ITreeItemRenderer; private var _layoutItems:Vector. = new []; private var _unrenderedItems:Array = []; private var _defaultItemRendererStorage:ItemRendererFactoryStorage = new ItemRendererFactoryStorage(); private var _itemStorageMap:Object = {}; private var _itemRendererMap:Dictionary = new Dictionary(true); private var _minimumItemCount:int; public function calculateNavigationDestination(location:Vector., keyCode:uint, result:Vector.):void { var displayIndex:int = this.locationToDisplayIndex(location, false); if(displayIndex == -1) { throw new ArgumentError(""Cannot calculate navigation destination for location: "" + location); } var newDisplayIndex:int = this._layout.calculateNavigationDestination(this._layoutItems, displayIndex, keyCode, this._layoutResult); this.displayIndexToLocation(newDisplayIndex, result); } public function getScrollPositionForLocation(location:Vector., result:Point = null):Point { if(!result) { result = new Point(); } var displayIndex:int = this.locationToDisplayIndex(location, true); if(displayIndex == -1) { throw new ArgumentError(""Cannot calculate scroll position for location: "" + location); } return this._layout.getScrollPositionForIndex(displayIndex, this._layoutItems, 0, 0, this._actualVisibleWidth, this._actualVisibleHeight, result); } public function getNearestScrollPositionForIndex(location:Vector., result:Point = null):Point { if(!result) { result = new Point(); } var displayIndex:int = this.locationToDisplayIndex(location, true); if(displayIndex == -1) { throw new ArgumentError(""Cannot calculate nearest scroll position for location: "" + location); } return this._layout.getNearestScrollPositionForIndex(displayIndex, this._horizontalScrollPosition, this._verticalScrollPosition, this._layoutItems, 0, 0, this._actualVisibleWidth, this._actualVisibleHeight, result); } public function itemToItemRenderer(item:Object):ITreeItemRenderer { if(item is XML || item is XMLList) { return ITreeItemRenderer(this._itemRendererMap[item.toXMLString()]); } return ITreeItemRenderer(this._itemRendererMap[item]); } override public function dispose():void { this.refreshInactiveItemRenderers(null, true); if(this._itemStorageMap) { for(var factoryID:String in this._itemStorageMap) { this.refreshInactiveItemRenderers(factoryID, true); } } this.owner = null; this.dataProvider = null; this.layout = null; super.dispose(); } override protected function draw():void { var dataInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_DATA); var scrollInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_SCROLL); var sizeInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_SIZE); var selectionInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_SELECTED); var itemRendererInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_ITEM_RENDERER_FACTORY); var stylesInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_STYLES); var stateInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_STATE); var layoutInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_LAYOUT); //scrolling only affects the layout is requiresLayoutOnScroll is true if(!layoutInvalid && scrollInvalid && this._layout && this._layout.requiresLayoutOnScroll) { layoutInvalid = true; } var basicsInvalid:Boolean = sizeInvalid || dataInvalid || layoutInvalid || itemRendererInvalid; var oldIgnoreRendererResizing:Boolean = this._ignoreRendererResizing; this._ignoreRendererResizing = true; var oldIgnoreLayoutChanges:Boolean = this._ignoreLayoutChanges; this._ignoreLayoutChanges = true; if(scrollInvalid || sizeInvalid) { this.refreshViewPortBounds(); } if(basicsInvalid) { this.refreshInactiveItemRenderers(null, itemRendererInvalid); if(this._itemStorageMap) { for(var factoryID:String in this._itemStorageMap) { this.refreshInactiveItemRenderers(factoryID, itemRendererInvalid); } } } if(dataInvalid || layoutInvalid || itemRendererInvalid) { this.refreshLayoutTypicalItem(); } if(basicsInvalid) { this.refreshItemRenderers(); } if(selectionInvalid || basicsInvalid) { //unlike resizing renderers and layout changes, we only want to //stop listening for selection changes when we're forcibly //updating selection. other property changes on item renderers //can validly change selection, and we need to detect that. var oldIgnoreSelectionChanges:Boolean = this._ignoreSelectionChanges; this._ignoreSelectionChanges = true; this.refreshSelection(); this._ignoreSelectionChanges = oldIgnoreSelectionChanges; } if(stateInvalid || basicsInvalid) { this.refreshEnabled(); } this._ignoreLayoutChanges = oldIgnoreLayoutChanges; if(stateInvalid || selectionInvalid || stylesInvalid || basicsInvalid) { this._layout.layout(this._layoutItems, this._viewPortBounds, this._layoutResult); } this._ignoreRendererResizing = oldIgnoreRendererResizing; this._contentX = this._layoutResult.contentX; this._contentY = this._layoutResult.contentY; this.saveMeasurements(this._layoutResult.contentWidth, this._layoutResult.contentHeight, this._layoutResult.contentWidth, this._layoutResult.contentHeight); this._actualVisibleWidth = this._layoutResult.viewPortWidth; this._actualVisibleHeight = this._layoutResult.viewPortHeight; this._actualMinVisibleWidth = this._layoutResult.viewPortWidth; this._actualMinVisibleHeight = this._layoutResult.viewPortHeight; //final validation to avoid juggler next frame issues this.validateRenderers(); } private function displayIndexToLocation(displayIndex:int, result:Vector.):void { } private var _displayIndex:int; private function locationToDisplayIndex(location:Vector., returnNearestIfBranchNotOpen:Boolean):int { this._displayIndex = -1; var result:Object = this.locationToDisplayIndexAtBranch(new [], location, returnNearestIfBranchNotOpen); if(result !== null) { return this._displayIndex; } return -1; } private function locationToDisplayIndexAtBranch(locationOfBranch:Vector., locationToFind:Vector., returnNearestIfBranchNotOpen:Boolean):Object { var childCount:int = this._dataProvider.getLengthAtLocation(locationOfBranch); for(var i:int = 0; i < childCount; i++) { this._displayIndex++; locationOfBranch[locationOfBranch.length] = i; var child:Object = this._dataProvider.getItemAtLocation(locationOfBranch); if(locationOfBranch.length == locationToFind.length) { var every:Boolean = locationOfBranch.every(function(item:int, index:int, source:Vector.):Boolean { return item === locationToFind[index]; }); if(every) { return child; } } if(this._dataProvider.isBranch(child)) { if(this.owner.isBranchOpen(child)) { var result:Object = this.locationToDisplayIndexAtBranch(locationOfBranch, locationToFind, returnNearestIfBranchNotOpen); if(result) { return result; } } else if(returnNearestIfBranchNotOpen) { //if the location is inside a closed branch //return that branch every = locationOfBranch.every(function(item:int, index:int, source:Vector.):Boolean { return item === locationToFind[index]; }); if(every) { return child; } } } locationOfBranch.length--; } //location was not found! return null; } private function refreshViewPortBounds():void { var needsMinWidth:Boolean = this._explicitMinVisibleWidth !== this._explicitMinVisibleWidth; //isNaN var needsMinHeight:Boolean = this._explicitMinVisibleHeight !== this._explicitMinVisibleHeight; //isNaN this._viewPortBounds.x = 0; this._viewPortBounds.y = 0; this._viewPortBounds.scrollX = this._horizontalScrollPosition; this._viewPortBounds.scrollY = this._verticalScrollPosition; this._viewPortBounds.explicitWidth = this._explicitVisibleWidth; this._viewPortBounds.explicitHeight = this._explicitVisibleHeight; if(needsMinWidth) { this._viewPortBounds.minWidth = 0; } else { this._viewPortBounds.minWidth = this._explicitMinVisibleWidth; } if(needsMinHeight) { this._viewPortBounds.minHeight = 0; } else { this._viewPortBounds.minHeight = this._explicitMinVisibleHeight; } this._viewPortBounds.maxWidth = this._maxVisibleWidth; this._viewPortBounds.maxHeight = this._maxVisibleHeight; } private function refreshLayoutTypicalItem():void { var virtualLayout:IVirtualLayout = this._layout as IVirtualLayout; if(virtualLayout === null || !virtualLayout.useVirtualLayout) { //the old layout was virtual, but this one isn't if(!this._typicalItemIsInDataProvider && this._typicalItemRenderer !== null) { //it's safe to destroy this renderer this.destroyItemRenderer(this._typicalItemRenderer); this._typicalItemRenderer = null; } return; } var typicalItemLocation:Vector. = null; var newTypicalItemIsInDataProvider:Boolean = false; var typicalItem:Object = this._typicalItem; if(typicalItem !== null) { if(this._dataProvider !== null) { typicalItemLocation = this._dataProvider.getItemLocation(typicalItem); newTypicalItemIsInDataProvider = typicalItemLocation !== null && typicalItemLocation.length > 0; } } else { if(this._dataProvider !== null && this._dataProvider.getLengthAtLocation() > 0) { newTypicalItemIsInDataProvider = true; typicalItem = this._dataProvider.getItemAt(0); typicalItemLocation = new [0]; } } //#1645 The typicalItem can be null if the data provider contains //a null value at index 0. this is the only time we allow null. if(typicalItem !== null || newTypicalItemIsInDataProvider) { var typicalItemRenderer:ITreeItemRenderer = this.itemToItemRenderer(typicalItem); if(typicalItemRenderer !== null) { //at this point, the item already has an item renderer. //(this doesn't necessarily mean that the current typical //item was the typical item last time this function was //called) //the location may have changed if items were added, //removed or reordered in the data provider typicalItemRenderer.location = typicalItemLocation; } if(typicalItemRenderer === null && this._typicalItemRenderer !== null) { //the typical item has changed, and doesn't have an item //renderer yet. the previous typical item had an item //renderer, so we will try to reuse it. //we can reuse the existing typical item renderer if the old //typical item wasn't in the data provider. otherwise, it //may still be needed for the same item. var canReuse:Boolean = !this._typicalItemIsInDataProvider; var oldTypicalItemRemoved:Boolean = this._typicalItemIsInDataProvider && this._dataProvider !== null && this._dataProvider.getItemLocation(this._typicalItemRenderer.data) === null; if(!canReuse && oldTypicalItemRemoved) { //special case: if the old typical item was in the data //provider, but it has been removed, it's safe to reuse. canReuse = true; } if(canReuse) { //we can't reuse if the factoryID has changed, though! var factoryID:String = null; if(this._factoryIDFunction !== null) { factoryID = this.getFactoryID(typicalItem, typicalItemLocation); } if(this._typicalItemRenderer.factoryID !== factoryID) { canReuse = false; } } if(canReuse) { //we can reuse the item renderer used for the old //typical item! //if the old typical item was in the data provider, //remove it from the renderer map. if(this._typicalItemIsInDataProvider) { var oldData:Object = this._typicalItemRenderer.data; if(oldData is XML || oldData is XMLList) { delete this._itemRendererMap[oldData.toXMLString()]; } else { delete this._itemRendererMap[oldData]; } } typicalItemRenderer = this._typicalItemRenderer; typicalItemRenderer.data = typicalItem; typicalItemRenderer.location = typicalItemLocation; //if the new typical item is in the data provider, add it //to the renderer map. if(newTypicalItemIsInDataProvider) { if(typicalItem is XML || typicalItem is XMLList) { this._itemRendererMap[typicalItem.toXMLString()] = typicalItemRenderer; } else { this._itemRendererMap[typicalItem] = typicalItemRenderer; } } } } if(typicalItemRenderer === null) { //if we still don't have a typical item renderer, we need to //create a new one. typicalItemRenderer = this.createItemRenderer(typicalItem, typicalItemLocation, 0, false, !newTypicalItemIsInDataProvider); if(!this._typicalItemIsInDataProvider && this._typicalItemRenderer !== null) { //get rid of the old typical item renderer if it isn't //needed anymore. since it was not in the data //provider, we don't need to mess with the renderer map //dictionary or dispatch any events. this.destroyItemRenderer(this._typicalItemRenderer); this._typicalItemRenderer = null; } } } virtualLayout.typicalItem = DisplayObject(typicalItemRenderer); this._typicalItemRenderer = typicalItemRenderer; this._typicalItemIsInDataProvider = newTypicalItemIsInDataProvider; if(this._typicalItemRenderer !== null && !this._typicalItemIsInDataProvider) { //we need to know if this item renderer resizes to adjust the //layout because the layout may use this item renderer to resize //the other item renderers this._typicalItemRenderer.addEventListener(FeathersEventType.RESIZE, itemRenderer_resizeHandler); } } private function refreshItemRenderers():void { if(this._typicalItemRenderer !== null && this._typicalItemIsInDataProvider) { var storage:ItemRendererFactoryStorage = this.factoryIDToStorage(this._typicalItemRenderer.factoryID); var inactiveItemRenderers:Vector. = storage.inactiveItemRenderers; var activeItemRenderers:Vector. = storage.activeItemRenderers; //this renderer is already is use by the typical item, so we //don't want to allow it to be used by other items. var inactiveIndex:int = inactiveItemRenderers.indexOf(this._typicalItemRenderer); if(inactiveIndex >= 0) { inactiveItemRenderers[inactiveIndex] = null; } //if refreshLayoutTypicalItem() was called, it will have already //added the typical item renderer to the active renderers. if //not, we need to do it here. var activeRendererCount:int = activeItemRenderers.length; if(activeRendererCount == 0) { activeItemRenderers[activeRendererCount] = this._typicalItemRenderer; } } this.findUnrenderedData(); this.recoverInactiveItemRenderers(this._defaultItemRendererStorage); if(this._itemStorageMap) { for(var factoryID:String in this._itemStorageMap) { storage = ItemRendererFactoryStorage(this._itemStorageMap[factoryID]); this.recoverInactiveItemRenderers(storage); } } this.renderUnrenderedData(); this.freeInactiveItemRenderers(this._defaultItemRendererStorage, this._minimumItemCount); if(this._itemStorageMap) { for(factoryID in this._itemStorageMap) { storage = ItemRendererFactoryStorage(this._itemStorageMap[factoryID]); this.freeInactiveItemRenderers(storage, 1); } } this._updateForDataReset = false; } private function findTotalLayoutCount(location:Vector.):int { var itemCount:int = 0; if(this._dataProvider !== null) { itemCount = this._dataProvider.getLengthAtLocation(location); } var result:int = itemCount; for(var i:int = 0; i < itemCount; i++) { location[location.length] = i; var item:Object = this._dataProvider.getItemAtLocation(location); if(this._dataProvider.isBranch(item) && this._openBranches.contains(item)) { result += this.findTotalLayoutCount(location); } location.length--; } return result; } private function findUnrenderedDataForLocation(location:Vector., currentIndex:int):int { var virtualLayout:IVirtualLayout = this._layout as IVirtualLayout; var useVirtualLayout:Boolean = virtualLayout !== null && virtualLayout.useVirtualLayout; var itemCount:int = 0; if(this._dataProvider !== null) { itemCount = this._dataProvider.getLengthAtLocation(location); } for(var i:int = 0; i < itemCount; i++) { location[location.length] = i; var item:Object = this._dataProvider.getItemAtLocation(location); if(useVirtualLayout && HELPER_VECTOR.indexOf(currentIndex) == -1) { if(this._typicalItemRenderer !== null && this._typicalItemIsInDataProvider && this._typicalItemRenderer.data === item) { //the index may have changed if items were added, removed, //or reordered in the data provider this._typicalItemRenderer.layoutIndex = currentIndex; } this._layoutItems[currentIndex] = null; } else { this.findRendererForItem(item, location.slice(), currentIndex); } currentIndex++; if(this._dataProvider.isBranch(item) && this._openBranches.contains(item)) { currentIndex = this.findUnrenderedDataForLocation(location, currentIndex); } location.length--; } return currentIndex; } private function findUnrenderedData():void { LOCATION_HELPER_VECTOR.length = 0; var totalLayoutCount:int = this.findTotalLayoutCount(LOCATION_HELPER_VECTOR); LOCATION_HELPER_VECTOR.length = 0; this._layoutItems.length = totalLayoutCount; var virtualLayout:IVirtualLayout = this._layout as IVirtualLayout; var useVirtualLayout:Boolean = virtualLayout !== null && virtualLayout.useVirtualLayout; if(useVirtualLayout) { var point:Point = Pool.getPoint(); virtualLayout.measureViewPort(totalLayoutCount, this._viewPortBounds, point); var viewPortWidth:Number = point.x; var viewPortHeight:Number = point.y; Pool.putPoint(point); virtualLayout.getVisibleIndicesAtScrollPosition(this._horizontalScrollPosition, this._verticalScrollPosition, viewPortWidth, viewPortHeight, totalLayoutCount, HELPER_VECTOR); if(this._typicalItemRenderer !== null) { var minimumTypicalItemEdge:Number = this._typicalItemRenderer.height; if(this._typicalItemRenderer.width < minimumTypicalItemEdge) { minimumTypicalItemEdge = this._typicalItemRenderer.width; } var maximumViewPortEdge:Number = viewPortWidth; if(viewPortHeight > viewPortWidth) { maximumViewPortEdge = viewPortHeight; } this._minimumItemCount = Math.ceil(maximumViewPortEdge / minimumTypicalItemEdge) + 1; } else { this._minimumItemCount = 1; } } LOCATION_HELPER_VECTOR.length = 0; this.findUnrenderedDataForLocation(LOCATION_HELPER_VECTOR, 0); LOCATION_HELPER_VECTOR.length = 0; //update the typical item renderer's visibility if(this._typicalItemRenderer !== null) { if(useVirtualLayout && this._typicalItemIsInDataProvider) { var index:int = HELPER_VECTOR.indexOf(this._typicalItemRenderer.layoutIndex); if(index >= 0) { this._typicalItemRenderer.visible = true; } else { this._typicalItemRenderer.visible = false; //uncomment these lines to see a hidden typical item for //debugging purposes... /*this._typicalItemRenderer.visible = true; this._typicalItemRenderer.x = this._horizontalScrollPosition; this._typicalItemRenderer.y = this._verticalScrollPosition;*/ } } else { this._typicalItemRenderer.visible = this._typicalItemIsInDataProvider; } } HELPER_VECTOR.length = 0; } private function findRendererForItem(item:Object, location:Vector., layoutIndex:int):void { var itemRenderer:ITreeItemRenderer = this.itemToItemRenderer(item); if(this._factoryIDFunction !== null && itemRenderer !== null) { var newFactoryID:String = this.getFactoryID(itemRenderer.data, location); if(newFactoryID !== itemRenderer.factoryID) { itemRenderer = null; if(item is XML || item is XMLList) { delete this._itemRendererMap[item.toXMLString()]; } else { delete this._itemRendererMap[item]; } } } if(itemRenderer !== null) { //the indices may have changed if items were added, removed, //or reordered in the data provider itemRenderer.location = location; itemRenderer.layoutIndex = layoutIndex; itemRenderer.isOpen = this._dataProvider.isBranch(item) && this._openBranches.contains(item); if(this._updateForDataReset) { //similar to calling updateItemAt(), replacing the data //provider or resetting its source means that we should //trick the item renderer into thinking it has new data. //many developers seem to expect this behavior, so while //it's not the most optimal for performance, it saves on //support time in the forums. thankfully, it's still //somewhat optimized since the same item renderer will //receive the same data, and the children generally //won't have changed much, if at all. itemRenderer.data = null; itemRenderer.data = item; } //the typical item renderer is a special case, and we will //have already put it into the active renderers, so we don't //want to do it again! if(this._typicalItemRenderer !== itemRenderer) { var storage:ItemRendererFactoryStorage = this.factoryIDToStorage(itemRenderer.factoryID); var activeItemRenderers:Vector. = storage.activeItemRenderers; var inactiveItemRenderers:Vector. = storage.inactiveItemRenderers; activeItemRenderers[activeItemRenderers.length] = itemRenderer; var inactiveIndex:int = inactiveItemRenderers.indexOf(itemRenderer); if(inactiveIndex >= 0) { inactiveItemRenderers.removeAt(inactiveIndex); } else { throw new IllegalOperationError(""TreeDataViewPort: item renderer map contains bad data. This may be caused by duplicate items in the data provider, which is not allowed.""); } } itemRenderer.visible = true; this._layoutItems[layoutIndex] = DisplayObject(itemRenderer); } else { var pushIndex:int = this._unrenderedItems.length; this._unrenderedItems[pushIndex] = location; pushIndex++; this._unrenderedItems[pushIndex] = layoutIndex; } } private function renderUnrenderedData():void { LOCATION_HELPER_VECTOR.length = 2; var rendererCount:int = this._unrenderedItems.length; for(var i:int = 0; i < rendererCount; i += 2) { var location:Vector. = this._unrenderedItems.shift(); var layoutIndex:int = this._unrenderedItems.shift(); var item:Object = this._dataProvider.getItemAtLocation(location); var itemRenderer:ITreeItemRenderer = this.createItemRenderer( item, location, layoutIndex, true, false); itemRenderer.visible = true; this._layoutItems[layoutIndex] = DisplayObject(itemRenderer); } LOCATION_HELPER_VECTOR.length = 0; } private function refreshInactiveItemRenderers(factoryID:String, itemRendererTypeIsInvalid:Boolean):void { if(factoryID !== null) { var storage:ItemRendererFactoryStorage = ItemRendererFactoryStorage(this._itemStorageMap[factoryID]); } else { storage = this._defaultItemRendererStorage; } var temp:Vector. = storage.inactiveItemRenderers; storage.inactiveItemRenderers = storage.activeItemRenderers; storage.activeItemRenderers = temp; if(storage.activeItemRenderers.length > 0) { throw new IllegalOperationError(""TreeDataViewPort: active renderers should be empty.""); } if(itemRendererTypeIsInvalid) { this.recoverInactiveItemRenderers(storage); this.freeInactiveItemRenderers(storage, 0); if(this._typicalItemRenderer && this._typicalItemRenderer.factoryID === factoryID) { if(this._typicalItemIsInDataProvider) { var item:Object = this._typicalItemRenderer.data; if(item is XML || item is XMLList) { delete this._itemRendererMap[item.toXMLString()]; } else { delete this._itemRendererMap[item]; } } this.destroyItemRenderer(this._typicalItemRenderer); this._typicalItemRenderer = null; this._typicalItemIsInDataProvider = false; } } this._layoutItems.length = 0; } private function recoverInactiveItemRenderers(storage:ItemRendererFactoryStorage):void { var inactiveItemRenderers:Vector. = storage.inactiveItemRenderers; var itemCount:int = inactiveItemRenderers.length; for(var i:int = 0; i < itemCount; i++) { var itemRenderer:ITreeItemRenderer = inactiveItemRenderers[i]; if(itemRenderer === null || itemRenderer.data === null) { continue; } this._owner.dispatchEventWith(FeathersEventType.RENDERER_REMOVE, false, itemRenderer); var item:Object = itemRenderer.data; if(item is XML || item is XMLList) { delete this._itemRendererMap[item.toXMLString()]; } else { delete this._itemRendererMap[item]; } } } private function freeInactiveItemRenderers(storage:ItemRendererFactoryStorage, minimumItemCount:int):void { var inactiveItemRenderers:Vector. = storage.inactiveItemRenderers; var activeItemRenderers:Vector. = storage.activeItemRenderers; var activeItemRenderersCount:int = activeItemRenderers.length; //we may keep around some extra renderers to avoid too much //allocation and garbage collection. they'll be hidden. var itemCount:int = inactiveItemRenderers.length; var keepCount:int = minimumItemCount - activeItemRenderersCount; if(keepCount > itemCount) { keepCount = itemCount; } for(var i:int = 0; i < keepCount; i++) { var itemRenderer:ITreeItemRenderer = inactiveItemRenderers.shift(); if(!itemRenderer) { keepCount++; if(itemCount < keepCount) { keepCount = itemCount; } continue; } itemRenderer.data = null; itemRenderer.location = null; itemRenderer.visible = false; activeItemRenderers[activeItemRenderersCount] = itemRenderer; activeItemRenderersCount++; } itemCount -= keepCount; for(i = 0; i < itemCount; i++) { itemRenderer = inactiveItemRenderers.shift(); if(!itemRenderer) { continue; } this.destroyItemRenderer(itemRenderer); } } private function createItemRenderer(item:Object, location:Vector., layoutIndex:int, useCache:Boolean, isTemporary:Boolean):ITreeItemRenderer { var factoryID:String = null; if(this._factoryIDFunction !== null) { factoryID = this.getFactoryID(item, location); } var itemRendererFactory:Function = this.factoryIDToFactory(factoryID); var storage:ItemRendererFactoryStorage = this.factoryIDToStorage(factoryID); var inactiveItemRenderers:Vector. = storage.inactiveItemRenderers; var activeItemRenderers:Vector. = storage.activeItemRenderers; var itemRenderer:ITreeItemRenderer; do { if(!useCache || isTemporary || inactiveItemRenderers.length == 0) { if(itemRendererFactory !== null) { itemRenderer = ITreeItemRenderer(itemRendererFactory()); } else { itemRenderer = ITreeItemRenderer(new this._itemRendererType()); } if(this._customItemRendererStyleName && this._customItemRendererStyleName.length > 0) { itemRenderer.styleNameList.add(this._customItemRendererStyleName); } this.addChild(DisplayObject(itemRenderer)); } else { itemRenderer = inactiveItemRenderers.shift(); } //wondering why this all is in a loop? //_inactiveRenderers.shift() may return null because we're //storing null values instead of calling splice() to improve //performance. } while(!itemRenderer); itemRenderer.data = item; itemRenderer.owner = this._owner; itemRenderer.factoryID = factoryID; itemRenderer.location = location; itemRenderer.layoutIndex = layoutIndex; var isBranch:Boolean = this._dataProvider !== null && this._dataProvider.isBranch(item); itemRenderer.isBranch = isBranch; itemRenderer.isOpen = isBranch && this._openBranches.contains(item); if(!isTemporary) { if(item is XML || item is XMLList) { this._itemRendererMap[item.toXMLString()] = itemRenderer; } else { this._itemRendererMap[item] = itemRenderer; } activeItemRenderers[activeItemRenderers.length] = itemRenderer; itemRenderer.addEventListener(Event.TRIGGERED, itemRenderer_triggeredHandler); itemRenderer.addEventListener(Event.CHANGE, itemRenderer_changeHandler); itemRenderer.addEventListener(FeathersEventType.RESIZE, itemRenderer_resizeHandler); this._owner.dispatchEventWith(FeathersEventType.RENDERER_ADD, false, itemRenderer); } return itemRenderer; } private function destroyItemRenderer(itemRenderer:ITreeItemRenderer):void { itemRenderer.removeEventListener(Event.TRIGGERED, itemRenderer_triggeredHandler); itemRenderer.removeEventListener(Event.CHANGE, itemRenderer_changeHandler); itemRenderer.removeEventListener(FeathersEventType.RESIZE, itemRenderer_resizeHandler); itemRenderer.owner = null; itemRenderer.data = null; itemRenderer.location = null; itemRenderer.layoutIndex = -1; itemRenderer.factoryID = null; this.removeChild(DisplayObject(itemRenderer), true); } private function getFactoryID(item:Object, location:Vector.):String { if(this._factoryIDFunction === null) { return null; } if(this._factoryIDFunction.length == 2) { return this._factoryIDFunction(item, location); } return this._factoryIDFunction(item); } private function factoryIDToFactory(id:String):Function { if(id !== null) { if(id in this._itemRendererFactories) { return this._itemRendererFactories[id] as Function; } else { throw new ReferenceError(""Cannot find item renderer factory for ID \\"""" + id + ""\\"".""); } } return this._itemRendererFactory; } private function factoryIDToStorage(id:String):ItemRendererFactoryStorage { if(id !== null) { if(id in this._itemStorageMap) { return ItemRendererFactoryStorage(this._itemStorageMap[id]); } var storage:ItemRendererFactoryStorage = new ItemRendererFactoryStorage(); this._itemStorageMap[id] = storage; return storage; } return this._defaultItemRendererStorage; } private function invalidateParent(flag:String = INVALIDATION_FLAG_ALL):void { Scroller(this.parent).invalidate(flag); } private function refreshSelection():void { for each(var item:DisplayObject in this._layoutItems) { var itemRenderer:ITreeItemRenderer = item as ITreeItemRenderer; if(itemRenderer !== null) { itemRenderer.isSelected = itemRenderer.data === this._selectedItem; } } } private function refreshEnabled():void { for each(var item:DisplayObject in this._layoutItems) { var control:IFeathersControl = item as IFeathersControl; if(control !== null) { control.isEnabled = this._isEnabled; } } } private function validateRenderers():void { var itemCount:int = this._layoutItems.length; for(var i:int = 0; i < itemCount; i++) { var item:IValidating = this._layoutItems[i] as IValidating; if(item !== null) { item.validate(); } } } private function layout_changeHandler(event:Event):void { if(this._ignoreLayoutChanges) { return; } this.invalidate(INVALIDATION_FLAG_LAYOUT); this.invalidateParent(INVALIDATION_FLAG_LAYOUT); } private function dataProvider_changeHandler(event:Event):void { this.invalidate(INVALIDATION_FLAG_DATA); } private function itemRenderer_triggeredHandler(event:Event):void { var itemRenderer:ITreeItemRenderer = ITreeItemRenderer(event.currentTarget); this.parent.dispatchEventWith(Event.TRIGGERED, false, itemRenderer.data); } private function itemRenderer_changeHandler(event:Event):void { if(this._ignoreSelectionChanges) { return; } var itemRenderer:ITreeItemRenderer = ITreeItemRenderer(event.currentTarget); if(!this._isSelectable || this._owner.isScrolling) { itemRenderer.isSelected = false; return; } var isSelected:Boolean = itemRenderer.isSelected; if(isSelected) { this.selectedItem = itemRenderer.data; } else { this.selectedItem = null; } } private function itemRenderer_resizeHandler(event:Event):void { if(this._ignoreRendererResizing) { return; } this.invalidate(INVALIDATION_FLAG_LAYOUT); this.invalidateParent(INVALIDATION_FLAG_LAYOUT); if(event.currentTarget === this._typicalItemRenderer && !this._typicalItemIsInDataProvider) { return; } var layout:IVariableVirtualLayout = this._layout as IVariableVirtualLayout; if(!layout || !layout.hasVariableItemDimensions) { return; } var itemRenderer:ITreeItemRenderer = ITreeItemRenderer(event.currentTarget); layout.resetVariableVirtualCacheAtIndex(itemRenderer.layoutIndex, DisplayObject(itemRenderer)); } private function openBranches_changeHandler(event:Event):void { this.invalidate(INVALIDATION_FLAG_DATA); } } } import feathers.controls.renderers.ITreeItemRenderer; class ItemRendererFactoryStorage { public function ItemRendererFactoryStorage() { } public var activeItemRenderers:Vector. = new []; public var inactiveItemRenderers:Vector. = new []; }",12482,False,2474.0642790540774,median "UIElement@ browserWindow; Window@ browserFilterWindow; ListView@ browserDirList; ListView@ browserFileList; LineEdit@ browserSearch; BrowserFile@ browserDragFile; Node@ browserDragNode; Component@ browserDragComponent; View3D@ resourceBrowserPreview; Scene@ resourcePreviewScene; Node@ resourcePreviewNode; Node@ resourcePreviewCameraNode; Node@ resourcePreviewLightNode; Light@ resourcePreviewLight; int browserSearchSortMode = 0; BrowserDir@ rootDir; Array browserFiles; Dictionary browserDirs; Array activeResourceTypeFilters; Array activeResourceDirFilters; Array browserFilesToScan; const uint BROWSER_WORKER_ITEMS_PER_TICK = 10; const uint BROWSER_SEARCH_LIMIT = 50; const int BROWSER_SORT_MODE_ALPHA = 1; const int BROWSER_SORT_MODE_SEARCH = 2; const int RESOURCE_TYPE_UNUSABLE = -2; const int RESOURCE_TYPE_UNKNOWN = -1; const int RESOURCE_TYPE_NOTSET = 0; const int RESOURCE_TYPE_SCENE = 1; const int RESOURCE_TYPE_SCRIPTFILE = 2; const int RESOURCE_TYPE_MODEL = 3; const int RESOURCE_TYPE_MATERIAL = 4; const int RESOURCE_TYPE_ANIMATION = 5; const int RESOURCE_TYPE_IMAGE = 6; const int RESOURCE_TYPE_SOUND = 7; const int RESOURCE_TYPE_TEXTURE = 8; const int RESOURCE_TYPE_FONT = 9; const int RESOURCE_TYPE_PREFAB = 10; const int RESOURCE_TYPE_TECHNIQUE = 11; const int RESOURCE_TYPE_PARTICLEEFFECT = 12; const int RESOURCE_TYPE_UIELEMENT = 13; const int RESOURCE_TYPE_UIELEMENTS = 14; const int RESOURCE_TYPE_ANIMATION_SETTINGS = 15; const int RESOURCE_TYPE_RENDERPATH = 16; const int RESOURCE_TYPE_TEXTURE_ATLAS = 17; const int RESOURCE_TYPE_2D_PARTICLE_EFFECT = 18; const int RESOURCE_TYPE_TEXTURE_3D = 19; const int RESOURCE_TYPE_CUBEMAP = 20; const int RESOURCE_TYPE_PARTICLEEMITTER = 21; const int RESOURCE_TYPE_2D_ANIMATION_SET = 22; // any resource type > 0 is valid const int NUMBER_OF_VALID_RESOURCE_TYPES = 22; const StringHash XML_TYPE_SCENE(""scene""); const StringHash XML_TYPE_NODE(""node""); const StringHash XML_TYPE_MATERIAL(""material""); const StringHash XML_TYPE_TECHNIQUE(""technique""); const StringHash XML_TYPE_PARTICLEEFFECT(""particleeffect""); const StringHash XML_TYPE_PARTICLEEMITTER(""particleemitter""); const StringHash XML_TYPE_TEXTURE(""texture""); const StringHash XML_TYPE_ELEMENT(""element""); const StringHash XML_TYPE_ELEMENTS(""elements""); const StringHash XML_TYPE_ANIMATION_SETTINGS(""animation""); const StringHash XML_TYPE_RENDERPATH(""renderpath""); const StringHash XML_TYPE_TEXTURE_ATLAS(""TextureAtlas""); const StringHash XML_TYPE_2D_PARTICLE_EFFECT(""particleEmitterConfig""); const StringHash XML_TYPE_TEXTURE_3D(""texture3d""); const StringHash XML_TYPE_CUBEMAP(""cubemap""); const StringHash XML_TYPE_SPRITER_DATA(""spriter_data""); const StringHash JSON_TYPE_SCENE(""scene""); const StringHash JSON_TYPE_NODE(""node""); const StringHash JSON_TYPE_MATERIAL(""material""); const StringHash JSON_TYPE_TECHNIQUE(""technique""); const StringHash JSON_TYPE_PARTICLEEFFECT(""particleeffect""); const StringHash JSON_TYPE_PARTICLEEMITTER(""particleemitter""); const StringHash JSON_TYPE_TEXTURE(""texture""); const StringHash JSON_TYPE_ELEMENT(""element""); const StringHash JSON_TYPE_ELEMENTS(""elements""); const StringHash JSON_TYPE_ANIMATION_SETTINGS(""animation""); const StringHash JSON_TYPE_RENDERPATH(""renderpath""); const StringHash JSON_TYPE_TEXTURE_ATLAS(""TextureAtlas""); const StringHash JSON_TYPE_2D_PARTICLE_EFFECT(""particleEmitterConfig""); const StringHash JSON_TYPE_TEXTURE_3D(""texture3d""); const StringHash JSON_TYPE_CUBEMAP(""cubemap""); const StringHash JSON_TYPE_SPRITER_DATA(""spriter_data""); const StringHash BINARY_TYPE_SCENE(""USCN""); const StringHash BINARY_TYPE_PACKAGE(""UPAK""); const StringHash BINARY_TYPE_COMPRESSED_PACKAGE(""ULZ4""); const StringHash BINARY_TYPE_ANGLESCRIPT(""ASBC""); const StringHash BINARY_TYPE_MODEL(""UMDL""); const StringHash BINARY_TYPE_SHADER(""USHD""); const StringHash BINARY_TYPE_ANIMATION(""UANI""); const StringHash EXTENSION_TYPE_TTF("".ttf""); const StringHash EXTENSION_TYPE_OTF("".otf""); const StringHash EXTENSION_TYPE_OGG("".ogg""); const StringHash EXTENSION_TYPE_WAV("".wav""); const StringHash EXTENSION_TYPE_DDS("".dds""); const StringHash EXTENSION_TYPE_PNG("".png""); const StringHash EXTENSION_TYPE_JPG("".jpg""); const StringHash EXTENSION_TYPE_JPEG("".jpeg""); const StringHash EXTENSION_TYPE_BMP("".bmp""); const StringHash EXTENSION_TYPE_TGA("".tga""); const StringHash EXTENSION_TYPE_KTX("".ktx""); const StringHash EXTENSION_TYPE_PVR("".pvr""); const StringHash EXTENSION_TYPE_OBJ("".obj""); const StringHash EXTENSION_TYPE_FBX("".fbx""); const StringHash EXTENSION_TYPE_COLLADA("".dae""); const StringHash EXTENSION_TYPE_BLEND("".blend""); const StringHash EXTENSION_TYPE_ANGELSCRIPT("".as""); const StringHash EXTENSION_TYPE_LUASCRIPT("".lua""); const StringHash EXTENSION_TYPE_HLSL("".hlsl""); const StringHash EXTENSION_TYPE_GLSL("".glsl""); const StringHash EXTENSION_TYPE_FRAGMENTSHADER("".frag""); const StringHash EXTENSION_TYPE_VERTEXSHADER("".vert""); const StringHash EXTENSION_TYPE_HTML("".html""); const StringHash TEXT_VAR_FILE_ID(""browser_file_id""); const StringHash TEXT_VAR_DIR_ID(""browser_dir_id""); const StringHash TEXT_VAR_RESOURCE_TYPE(""resource_type""); const StringHash TEXT_VAR_RESOURCE_DIR_ID(""resource_dir_id""); const int BROWSER_FILE_SOURCE_RESOURCE_DIR = 1; uint browserDirIndex = 1; uint browserFileIndex = 1; BrowserDir@ selectedBrowserDirectory; BrowserFile@ selectedBrowserFile; Text@ browserStatusMessage; Text@ browserResultsMessage; bool ignoreRefreshBrowserResults = false; String resourceDirsCache; void CreateResourceBrowser() { if (browserWindow !is null) return; CreateResourceBrowserUI(); InitResourceBrowserPreview(); RebuildResourceDatabase(); } void RebuildResourceDatabase() { if (browserWindow is null) return; String newResourceDirsCache = Join(cache.resourceDirs, ';'); ScanResourceDirectories(); if (newResourceDirsCache != resourceDirsCache) { resourceDirsCache = newResourceDirsCache; PopulateResourceDirFilters(); } PopulateBrowserDirectories(); PopulateResourceBrowserFilesByDirectory(rootDir); } void ScanResourceDirectories() { browserDirs.Clear(); browserFiles.Clear(); browserFilesToScan.Clear(); rootDir = BrowserDir(""""); browserDirs.Set("""", @rootDir); // collect all of the items and sort them afterwards for(uint i=0; i < cache.resourceDirs.length; ++i) { if (activeResourceDirFilters.Find(i) > -1) continue; ScanResourceDir(i); } } // used to stop ui from blocking while determining file types void DoResourceBrowserWork() { if (browserFilesToScan.length == 0) return; int counter = 0; bool updateBrowserUI = false; BrowserFile@ scanItem = browserFilesToScan[0]; while(counter < BROWSER_WORKER_ITEMS_PER_TICK) { scanItem.DetermainResourceType(); // next browserFilesToScan.Erase(0); if (browserFilesToScan.length > 0) @scanItem = browserFilesToScan[0]; else break; counter++; } if (browserFilesToScan.length > 0) browserStatusMessage.text = localization.Get(""Files left to scan: "" )+ browserFilesToScan.length; else browserStatusMessage.text = localization.Get(""Scan complete""); } void CreateResourceBrowserUI() { browserWindow = LoadEditorUI(""UI/EditorResourceBrowser.xml""); browserDirList = browserWindow.GetChild(""DirectoryList"", true); browserFileList = browserWindow.GetChild(""FileList"", true); browserSearch = browserWindow.GetChild(""Search"", true); browserStatusMessage = browserWindow.GetChild(""StatusMessage"", true); browserResultsMessage = browserWindow.GetChild(""ResultsMessage"", true); // browserWindow.visible = false; browserWindow.opacity = uiMaxOpacity; browserFilterWindow = LoadEditorUI(""UI/EditorResourceFilterWindow.xml""); CreateResourceFilterUI(); HideResourceFilterWindow(); int height = Min(ui.root.height / 4, 300); browserWindow.SetSize(900, height); browserWindow.SetPosition(35, ui.root.height - height - 25); CloseContextMenu(); ui.root.AddChild(browserWindow); ui.root.AddChild(browserFilterWindow); SubscribeToEvent(browserWindow.GetChild(""CloseButton"", true), ""Released"", ""HideResourceBrowserWindow""); SubscribeToEvent(browserWindow.GetChild(""RescanButton"", true), ""Released"", ""HandleRescanResourceBrowserClick""); SubscribeToEvent(browserWindow.GetChild(""FilterButton"", true), ""Released"", ""ToggleResourceFilterWindow""); SubscribeToEvent(browserDirList, ""SelectionChanged"", ""HandleResourceBrowserDirListSelectionChange""); SubscribeToEvent(browserSearch, ""TextChanged"", ""HandleResourceBrowserSearchTextChange""); SubscribeToEvent(browserFileList, ""ItemClicked"", ""HandleBrowserFileClick""); SubscribeToEvent(browserFileList, ""SelectionChanged"", ""HandleResourceBrowserFileListSelectionChange""); SubscribeToEvent(cache, ""FileChanged"", ""HandleFileChanged""); } void CreateResourceFilterUI() { UIElement@ options = browserFilterWindow.GetChild(""TypeOptions"", true); CheckBox@ toggleAllTypes = browserFilterWindow.GetChild(""ToggleAllTypes"", true); CheckBox@ toggleAllResourceDirs = browserFilterWindow.GetChild(""ToggleAllResourceDirs"", true); SubscribeToEvent(toggleAllTypes, ""Toggled"", ""HandleResourceTypeFilterToggleAllTypesToggled""); SubscribeToEvent(toggleAllResourceDirs, ""Toggled"", ""HandleResourceDirFilterToggleAllTypesToggled""); SubscribeToEvent(browserFilterWindow.GetChild(""CloseButton"", true), ""Released"", ""HideResourceFilterWindow""); int columns = 2; UIElement@ col1 = browserFilterWindow.GetChild(""TypeFilterColumn1"", true); UIElement@ col2 = browserFilterWindow.GetChild(""TypeFilterColumn2"", true); // use array to get sort of items Array sorted; for (int i=1; i <= NUMBER_OF_VALID_RESOURCE_TYPES; ++i) sorted.Push(ResourceType(i, ResourceTypeName(i))); // 2 unknown types are reserved for the top, the rest are alphabetized sorted.Sort(); sorted.Insert(0, ResourceType(RESOURCE_TYPE_UNKNOWN, ResourceTypeName(RESOURCE_TYPE_UNKNOWN)) ); sorted.Insert(0, ResourceType(RESOURCE_TYPE_UNUSABLE, ResourceTypeName(RESOURCE_TYPE_UNUSABLE)) ); int halfColumns = Ceil( float(sorted.length) / float(columns) ); for (uint i = 0; i < sorted.length; ++i) { ResourceType@ type = sorted[i]; UIElement@ resourceTypeHolder = UIElement(); if (i < halfColumns) col1.AddChild(resourceTypeHolder); else col2.AddChild(resourceTypeHolder); resourceTypeHolder.layoutMode = LM_HORIZONTAL; resourceTypeHolder.layoutSpacing = 4; Text@ label = Text(); label.style = ""EditorAttributeText""; label.text = type.name; CheckBox@ checkbox = CheckBox(); checkbox.name = type.id; checkbox.SetStyleAuto(); checkbox.vars[TEXT_VAR_RESOURCE_TYPE] = i; checkbox.checked = true; SubscribeToEvent(checkbox, ""Toggled"", ""HandleResourceTypeFilterToggled""); resourceTypeHolder.AddChild(checkbox); resourceTypeHolder.AddChild(label); } } void CreateDirList(BrowserDir@ dir, UIElement@ parentUI = null) { Text@ dirText = Text(); browserDirList.InsertItem(browserDirList.numItems, dirText, parentUI); dirText.style = ""FileSelectorListText""; dirText.text = dir.resourceKey.empty ? localization.Get(""Root"") : dir.name; dirText.name = dir.resourceKey; dirText.vars[TEXT_VAR_DIR_ID] = dir.resourceKey; // Sort directories alphetically browserSearchSortMode = BROWSER_SORT_MODE_ALPHA; dir.children.Sort(); for(uint i=0; i 0) fileText.dragDropMode = DD_SOURCE; { Text@ text = Text(); fileText.AddChild(text); text.style = ""FileSelectorListText""; text.text = file.fullname; text.name = file.resourceKey; } { Text@ text = Text(); fileText.AddChild(text); text.style = ""FileSelectorListText""; text.text = file.ResourceTypeName(); } if (file.resourceType == RESOURCE_TYPE_MATERIAL || file.resourceType == RESOURCE_TYPE_MODEL || file.resourceType == RESOURCE_TYPE_PARTICLEEFFECT || file.resourceType == RESOURCE_TYPE_PREFAB ) { SubscribeToEvent(fileText, ""DragBegin"", ""HandleBrowserFileDragBegin""); SubscribeToEvent(fileText, ""DragEnd"", ""HandleBrowserFileDragEnd""); } } void InitResourceBrowserPreview() { resourcePreviewScene = Scene(""PreviewScene""); resourcePreviewScene.CreateComponent(""Octree""); PhysicsWorld@ physicsWorld = resourcePreviewScene.CreateComponent(""PhysicsWorld""); physicsWorld.enabled = false; physicsWorld.gravity = Vector3(0.0, 0.0, 0.0); Node@ zoneNode = resourcePreviewScene.CreateChild(""Zone""); Zone@ zone = zoneNode.CreateComponent(""Zone""); zone.boundingBox = BoundingBox(-1000, 1000); zone.ambientColor = Color(0.15, 0.15, 0.15); zone.fogColor = Color(0, 0, 0); zone.fogStart = 10.0; zone.fogEnd = 100.0; resourcePreviewCameraNode = resourcePreviewScene.CreateChild(""PreviewCamera""); resourcePreviewCameraNode.position = Vector3(0, 0, -1.5); Camera@ camera = resourcePreviewCameraNode.CreateComponent(""Camera""); camera.nearClip = 0.1f; camera.farClip = 100.0f; resourcePreviewLightNode = resourcePreviewScene.CreateChild(""PreviewLight""); resourcePreviewLightNode.direction = Vector3(0.5, -0.5, 0.5); resourcePreviewLight = resourcePreviewLightNode.CreateComponent(""Light""); resourcePreviewLight.lightType = LIGHT_DIRECTIONAL; resourcePreviewLight.specularIntensity = 0.5; resourceBrowserPreview = browserWindow.GetChild(""ResourceBrowserPreview"", true); resourceBrowserPreview.SetFixedHeight(200); resourceBrowserPreview.SetFixedWidth(266); resourceBrowserPreview.SetView(resourcePreviewScene, camera); resourceBrowserPreview.autoUpdate = false; resourcePreviewNode = resourcePreviewScene.CreateChild(""PreviewNodeContainer""); SubscribeToEvent(resourceBrowserPreview, ""DragMove"", ""RotateResourceBrowserPreview""); RefreshBrowserPreview(); } // Opens a contextual menu based on what resource item was actioned void HandleBrowserFileClick(StringHash eventType, VariantMap& eventData) { if (eventData[""Button""].GetInt() != MOUSEB_RIGHT) return; UIElement@ uiElement = eventData[""Item""].GetPtr(); BrowserFile@ file = GetBrowserFileFromUIElement(uiElement); if (file is null) return; Array actions; if (file.resourceType == RESOURCE_TYPE_MATERIAL) { actions.Push(CreateBrowserFileActionMenu(""Edit"", ""HandleBrowserEditResource"", file)); } else if (file.resourceType == RESOURCE_TYPE_MODEL) { actions.Push(CreateBrowserFileActionMenu(""Instance Animated Model"", ""HandleBrowserInstantiateAnimatedModel"", file)); actions.Push(CreateBrowserFileActionMenu(""Instance Static Model"", ""HandleBrowserInstantiateStaticModel"", file)); } else if (file.resourceType == RESOURCE_TYPE_PREFAB) { actions.Push(CreateBrowserFileActionMenu(""Instance Prefab"", ""HandleBrowserInstantiatePrefab"", file)); actions.Push(CreateBrowserFileActionMenu(""Instance in Spawner"", ""HandleBrowserInstantiateInSpawnEditor"", file)); } else if (file.fileType == EXTENSION_TYPE_OBJ || file.fileType == EXTENSION_TYPE_COLLADA || file.fileType == EXTENSION_TYPE_FBX || file.fileType == EXTENSION_TYPE_BLEND) { actions.Push(CreateBrowserFileActionMenu(""Import Model"", ""HandleBrowserImportModel"", file)); actions.Push(CreateBrowserFileActionMenu(""Import Scene"", ""HandleBrowserImportScene"", file)); } else if (file.resourceType == RESOURCE_TYPE_UIELEMENT) { actions.Push(CreateBrowserFileActionMenu(""Open UI Layout"", ""HandleBrowserOpenUILayout"", file)); } else if (file.resourceType == RESOURCE_TYPE_SCENE) { actions.Push(CreateBrowserFileActionMenu(""Load Scene"", ""HandleBrowserLoadScene"", file)); } else if (file.resourceType == RESOURCE_TYPE_SCRIPTFILE) { actions.Push(CreateBrowserFileActionMenu(""Execute Script"", ""HandleBrowserRunScript"", file)); } else if (file.resourceType == RESOURCE_TYPE_PARTICLEEFFECT) { actions.Push(CreateBrowserFileActionMenu(""Edit"", ""HandleBrowserEditResource"", file)); } actions.Push(CreateBrowserFileActionMenu(""Open"", ""HandleBrowserOpenResource"", file)); ActivateContextMenu(actions); } BrowserDir@ GetBrowserDir(String path) { BrowserDir@ browserDir; browserDirs.Get(path, @browserDir); return browserDir; } // Makes sure the entire directory tree exists and new dir is linked to parent BrowserDir@ InitBrowserDir(String path) { BrowserDir@ browserDir; if (browserDirs.Get(path, @browserDir)) return browserDir; Array parts = path.Split('/'); Array finishedParts; if (parts.length > 0) { BrowserDir@ parent = rootDir; for( uint i = 0; i < parts.length; ++i ) { finishedParts.Push(parts[i]); String currentPath = Join(finishedParts, ""/""); if (!browserDirs.Get(currentPath, @browserDir)) { browserDir = BrowserDir(currentPath); browserDirs.Set(currentPath, @browserDir); parent.children.Push(browserDir); } @parent = browserDir; } return browserDir; } return null; } void ScanResourceDir(uint resourceDirIndex) { String resourceDir = cache.resourceDirs[resourceDirIndex]; ScanResourceDirFiles("""", resourceDirIndex); Array dirs = fileSystem.ScanDir(resourceDir, ""*"", SCAN_DIRS, true); for (uint i=0; i < dirs.length; ++i) { String path = dirs[i]; if (path.EndsWith(""."")) continue; InitBrowserDir(path); ScanResourceDirFiles(path, resourceDirIndex); } } void ScanResourceDirFiles(String path, uint resourceDirIndex) { String fullPath = cache.resourceDirs[resourceDirIndex] + path; if (!fileSystem.DirExists(fullPath)) return; BrowserDir@ dir = GetBrowserDir(path); if (dir is null) return; // get files in directory Array dirFiles = fileSystem.ScanDir(fullPath, ""*.*"", SCAN_FILES, false); // add new files for (uint x=0; x < dirFiles.length; x++) { String filename = dirFiles[x]; BrowserFile@ browserFile = dir.AddFile(filename, resourceDirIndex, BROWSER_FILE_SOURCE_RESOURCE_DIR); browserFiles.Push(browserFile); browserFilesToScan.Push(browserFile); } } bool ToggleResourceBrowserWindow() { if (browserWindow.visible == false) ShowResourceBrowserWindow(); else HideResourceBrowserWindow(); return true; } void ShowResourceBrowserWindow() { browserWindow.visible = true; browserWindow.BringToFront(); ui.focusElement = browserSearch; } void HideResourceBrowserWindow() { browserWindow.visible = false; } void ToggleResourceFilterWindow() { if (browserFilterWindow.visible) HideResourceFilterWindow(); else ShowResourceFilterWindow(); } void HideResourceFilterWindow() { browserFilterWindow.visible = false; } void ShowResourceFilterWindow() { int x = browserWindow.position.x + browserWindow.width - browserFilterWindow.width; int y = browserWindow.position.y - browserFilterWindow.height - 1; browserFilterWindow.position = IntVector2(x,y); browserFilterWindow.visible = true; browserFilterWindow.BringToFront(); } void PopulateResourceDirFilters() { UIElement@ resourceDirs = browserFilterWindow.GetChild(""DirFilters"", true); resourceDirs.RemoveAllChildren(); activeResourceDirFilters.Clear(); for (uint i=0; i < cache.resourceDirs.length; ++i) { UIElement@ resourceDirHolder = UIElement(); resourceDirs.AddChild(resourceDirHolder); resourceDirHolder.layoutMode = LM_HORIZONTAL; resourceDirHolder.layoutSpacing = 4; resourceDirHolder.SetFixedHeight(16); Text@ label = Text(); label.style = ""EditorAttributeText""; label.text = cache.resourceDirs[i].Replaced(fileSystem.programDir, """"); CheckBox@ checkbox = CheckBox(); checkbox.name = i; checkbox.SetStyleAuto(); checkbox.vars[TEXT_VAR_RESOURCE_DIR_ID] = i; checkbox.checked = true; SubscribeToEvent(checkbox, ""Toggled"", ""HandleResourceDirFilterToggled""); resourceDirHolder.AddChild(checkbox); resourceDirHolder.AddChild(label); } } void PopulateBrowserDirectories() { browserDirList.RemoveAllItems(); CreateDirList(rootDir); browserDirList.selection = 0; } void PopulateResourceBrowserFilesByDirectory(BrowserDir@ dir) { @selectedBrowserDirectory = dir; browserFileList.RemoveAllItems(); if (dir is null) return; Array files; for(uint x=0; x < dir.files.length; x++) { BrowserFile@ file = dir.files[x]; if (activeResourceTypeFilters.Find(file.resourceType) == -1) files.Push(file); } // Sort alphetically browserSearchSortMode = BROWSER_SORT_MODE_ALPHA; files.Sort(); PopulateResourceBrowserResults(files); browserResultsMessage.text = localization.Get(""Showing files: "") + files.length; } void PopulateResourceBrowserBySearch() { String query = browserSearch.text; Array scores; Array scored; Array filtered; { BrowserFile@ file; for(uint x=0; x < browserFiles.length; x++) { @file = browserFiles[x]; file.sortScore = -1; if (activeResourceTypeFilters.Find(file.resourceType) > -1) continue; if (activeResourceDirFilters.Find(file.resourceSourceIndex) > -1) continue; int find = file.fullname.Find(query, 0, false); if (find > -1) { int fudge = query.length - file.fullname.length; int score = find * int(Abs(fudge*2)) + int(Abs(fudge)); file.sortScore = score; scored.Push(file); scores.Push(score); } } } // cut this down for a faster sort if (scored.length > BROWSER_SEARCH_LIMIT) { scores.Sort(); int scoreThreshold = scores[BROWSER_SEARCH_LIMIT]; BrowserFile@ file; for(uint x=0;x@ files) { browserFileList.RemoveAllItems(); for(uint i=0; i < files.length; ++i) CreateFileList(files[i]); } void RefreshBrowserResults() { if (browserSearch.text.empty) { browserDirList.visible = true; PopulateResourceBrowserFilesByDirectory(selectedBrowserDirectory); } else { browserDirList.visible = false; PopulateResourceBrowserBySearch(); } } void HandleResourceTypeFilterToggleAllTypesToggled(StringHash eventType, VariantMap& eventData) { CheckBox@ checkbox = eventData[""Element""].GetPtr(); UIElement@ filterHolder = browserFilterWindow.GetChild(""TypeFilters"", true); Array children = filterHolder.GetChildren(true); ignoreRefreshBrowserResults = true; for(uint i=0; i < children.length; ++i) { CheckBox@ filter = children[i]; if (filter !is null) filter.checked = checkbox.checked; } ignoreRefreshBrowserResults = false; RefreshBrowserResults(); } void HandleResourceTypeFilterToggled(StringHash eventType, VariantMap& eventData) { CheckBox@ checkbox = eventData[""Element""].GetPtr(); if (!checkbox.vars.Contains(TEXT_VAR_RESOURCE_TYPE)) return; int resourceType = checkbox.GetVar(TEXT_VAR_RESOURCE_TYPE).GetInt(); int find = activeResourceTypeFilters.Find(resourceType); if (checkbox.checked && find != -1) activeResourceTypeFilters.Erase(find); else if (!checkbox.checked && find == -1) activeResourceTypeFilters.Push(resourceType); if (ignoreRefreshBrowserResults == false) RefreshBrowserResults(); } void HandleResourceDirFilterToggleAllTypesToggled(StringHash eventType, VariantMap& eventData) { CheckBox@ checkbox = eventData[""Element""].GetPtr(); UIElement@ filterHolder = browserFilterWindow.GetChild(""DirFilters"", true); Array children = filterHolder.GetChildren(true); ignoreRefreshBrowserResults = true; for(uint i=0; i < children.length; ++i) { CheckBox@ filter = children[i]; if (filter !is null) filter.checked = checkbox.checked; } ignoreRefreshBrowserResults = false; RebuildResourceDatabase(); } void HandleResourceDirFilterToggled(StringHash eventType, VariantMap& eventData) { CheckBox@ checkbox = eventData[""Element""].GetPtr(); if (!checkbox.vars.Contains(TEXT_VAR_RESOURCE_DIR_ID)) return; int resourceDir = checkbox.GetVar(TEXT_VAR_RESOURCE_DIR_ID).GetInt(); int find = activeResourceDirFilters.Find(resourceDir); if (checkbox.checked && find != -1) activeResourceDirFilters.Erase(find); else if (!checkbox.checked && find == -1) activeResourceDirFilters.Push(resourceDir); if (ignoreRefreshBrowserResults == false) RebuildResourceDatabase(); } void HandleRescanResourceBrowserClick(StringHash eventType, VariantMap& eventData) { RebuildResourceDatabase(); } void HandleResourceBrowserDirListSelectionChange(StringHash eventType, VariantMap& eventData) { if (browserDirList.selection == M_MAX_UNSIGNED) return; UIElement@ uiElement = browserDirList.GetItems()[browserDirList.selection]; BrowserDir@ dir = GetBrowserDir(uiElement.vars[TEXT_VAR_DIR_ID].GetString()); if (dir is null) return; PopulateResourceBrowserFilesByDirectory(dir); } void HandleResourceBrowserFileListSelectionChange(StringHash eventType, VariantMap& eventData) { if (browserFileList.selection == M_MAX_UNSIGNED) return; UIElement@ uiElement = browserFileList.GetItems()[browserFileList.selection]; BrowserFile@ file = GetBrowserFileFromUIElement(uiElement); if (file is null) return; if (resourcePreviewNode !is null) resourcePreviewNode.Remove(); resourcePreviewNode = resourcePreviewScene.CreateChild(""PreviewNodeContainer""); CreateResourcePreview(file.GetFullPath(), resourcePreviewNode); if (resourcePreviewNode !is null) { Array boxes; Array staticModels = resourcePreviewNode.GetComponents(""StaticModel"", true); Array animatedModels = resourcePreviewNode.GetComponents(""AnimatedModel"", true); for (uint i = 0; i < staticModels.length; ++i) boxes.Push(cast(staticModels[i]).worldBoundingBox); for (uint i = 0; i < animatedModels.length; ++i) boxes.Push(cast(animatedModels[i]).worldBoundingBox); if (boxes.length > 0) { Vector3 camPosition = Vector3(0.0, 0.0, -1.2); BoundingBox biggestBox = boxes[0]; for (uint i = 1; i < boxes.length; ++i) { if (boxes[i].size.length > biggestBox.size.length) biggestBox = boxes[i]; } resourcePreviewCameraNode.position = biggestBox.center + camPosition * biggestBox.size.length; } resourcePreviewScene.AddChild(resourcePreviewNode); RefreshBrowserPreview(); } } void HandleResourceBrowserSearchTextChange(StringHash eventType, VariantMap& eventData) { RefreshBrowserResults(); } BrowserFile@ GetBrowserFileFromId(uint id) { if (id == 0) return null; BrowserFile@ file; for(uint i=0; i(GetDrawableAtMousePostion()); if (model !is null) { AssignMaterial(model, browserDragFile.resourceKey); } } browserDragFile = null; browserDragComponent = null; browserDragNode = null; } void HandleFileChanged(StringHash eventType, VariantMap& eventData) { String filename = eventData[""FileName""].GetString(); BrowserFile@ file = GetBrowserFileFromPath(filename); if (file is null) { // TODO: new file logic when watchers are supported return; } else { file.FileChanged(); } } Menu@ CreateBrowserFileActionMenu(String text, String handler, BrowserFile@ browserFile = null) { Menu@ menu = CreateContextMenuItem(text, handler); if (browserFile !is null) menu.vars[TEXT_VAR_FILE_ID] = browserFile.id; return menu; } int GetResourceType(String path) { StringHash fileType; return GetResourceType(path, fileType); } int GetResourceType(String path, StringHash &out fileType, bool useCache = false) { if (GetExtensionType(path, fileType) || GetBinaryType(path, fileType, useCache) || GetXmlType(path, fileType, useCache)) return GetResourceType(fileType); return RESOURCE_TYPE_UNKNOWN; } int GetResourceType(StringHash fileType) { // binary fileTypes if (fileType == BINARY_TYPE_SCENE) return RESOURCE_TYPE_SCENE; else if (fileType == BINARY_TYPE_PACKAGE) return RESOURCE_TYPE_UNUSABLE; else if (fileType == BINARY_TYPE_COMPRESSED_PACKAGE) return RESOURCE_TYPE_UNUSABLE; else if (fileType == BINARY_TYPE_ANGLESCRIPT) return RESOURCE_TYPE_SCRIPTFILE; else if (fileType == BINARY_TYPE_MODEL) return RESOURCE_TYPE_MODEL; else if (fileType == BINARY_TYPE_SHADER) return RESOURCE_TYPE_UNUSABLE; else if (fileType == BINARY_TYPE_ANIMATION) return RESOURCE_TYPE_ANIMATION; // xml fileTypes else if (fileType == XML_TYPE_SCENE) return RESOURCE_TYPE_SCENE; else if (fileType == XML_TYPE_NODE) return RESOURCE_TYPE_PREFAB; else if(fileType == XML_TYPE_MATERIAL) return RESOURCE_TYPE_MATERIAL; else if(fileType == XML_TYPE_TECHNIQUE) return RESOURCE_TYPE_TECHNIQUE; else if(fileType == XML_TYPE_PARTICLEEFFECT) return RESOURCE_TYPE_PARTICLEEFFECT; else if(fileType == XML_TYPE_PARTICLEEMITTER) return RESOURCE_TYPE_PARTICLEEMITTER; else if(fileType == XML_TYPE_TEXTURE) return RESOURCE_TYPE_TEXTURE; else if(fileType == XML_TYPE_ELEMENT) return RESOURCE_TYPE_UIELEMENT; else if(fileType == XML_TYPE_ELEMENTS) return RESOURCE_TYPE_UIELEMENTS; else if (fileType == XML_TYPE_ANIMATION_SETTINGS) return RESOURCE_TYPE_ANIMATION_SETTINGS; else if (fileType == XML_TYPE_RENDERPATH) return RESOURCE_TYPE_RENDERPATH; else if (fileType == XML_TYPE_TEXTURE_ATLAS) return RESOURCE_TYPE_TEXTURE_ATLAS; else if (fileType == XML_TYPE_2D_PARTICLE_EFFECT) return RESOURCE_TYPE_2D_PARTICLE_EFFECT; else if (fileType == XML_TYPE_TEXTURE_3D) return RESOURCE_TYPE_TEXTURE_3D; else if (fileType == XML_TYPE_CUBEMAP) return RESOURCE_TYPE_CUBEMAP; else if (fileType == XML_TYPE_SPRITER_DATA) return RESOURCE_TYPE_2D_ANIMATION_SET; // JSON fileTypes else if (fileType == JSON_TYPE_SCENE) return RESOURCE_TYPE_SCENE; else if (fileType == JSON_TYPE_NODE) return RESOURCE_TYPE_PREFAB; else if(fileType == JSON_TYPE_MATERIAL) return RESOURCE_TYPE_MATERIAL; else if(fileType == JSON_TYPE_TECHNIQUE) return RESOURCE_TYPE_TECHNIQUE; else if(fileType == JSON_TYPE_PARTICLEEFFECT) return RESOURCE_TYPE_PARTICLEEFFECT; else if(fileType == JSON_TYPE_PARTICLEEMITTER) return RESOURCE_TYPE_PARTICLEEMITTER; else if(fileType == JSON_TYPE_TEXTURE) return RESOURCE_TYPE_TEXTURE; else if(fileType == JSON_TYPE_ELEMENT) return RESOURCE_TYPE_UIELEMENT; else if(fileType == JSON_TYPE_ELEMENTS) return RESOURCE_TYPE_UIELEMENTS; else if (fileType == JSON_TYPE_ANIMATION_SETTINGS) return RESOURCE_TYPE_ANIMATION_SETTINGS; else if (fileType == JSON_TYPE_RENDERPATH) return RESOURCE_TYPE_RENDERPATH; else if (fileType == JSON_TYPE_TEXTURE_ATLAS) return RESOURCE_TYPE_TEXTURE_ATLAS; else if (fileType == JSON_TYPE_2D_PARTICLE_EFFECT) return RESOURCE_TYPE_2D_PARTICLE_EFFECT; else if (fileType == JSON_TYPE_TEXTURE_3D) return RESOURCE_TYPE_TEXTURE_3D; else if (fileType == JSON_TYPE_CUBEMAP) return RESOURCE_TYPE_CUBEMAP; else if (fileType == JSON_TYPE_SPRITER_DATA) return RESOURCE_TYPE_2D_ANIMATION_SET; // extension fileTypes else if (fileType == EXTENSION_TYPE_TTF) return RESOURCE_TYPE_FONT; else if (fileType == EXTENSION_TYPE_OTF) return RESOURCE_TYPE_FONT; else if (fileType == EXTENSION_TYPE_OGG) return RESOURCE_TYPE_SOUND; else if(fileType == EXTENSION_TYPE_WAV) return RESOURCE_TYPE_SOUND; else if(fileType == EXTENSION_TYPE_DDS) return RESOURCE_TYPE_IMAGE; else if(fileType == EXTENSION_TYPE_PNG) return RESOURCE_TYPE_IMAGE; else if(fileType == EXTENSION_TYPE_JPG) return RESOURCE_TYPE_IMAGE; else if(fileType == EXTENSION_TYPE_JPEG) return RESOURCE_TYPE_IMAGE; else if(fileType == EXTENSION_TYPE_BMP) return RESOURCE_TYPE_IMAGE; else if(fileType == EXTENSION_TYPE_TGA) return RESOURCE_TYPE_IMAGE; else if(fileType == EXTENSION_TYPE_KTX) return RESOURCE_TYPE_IMAGE; else if(fileType == EXTENSION_TYPE_PVR) return RESOURCE_TYPE_IMAGE; else if(fileType == EXTENSION_TYPE_OBJ) return RESOURCE_TYPE_UNUSABLE; else if(fileType == EXTENSION_TYPE_FBX) return RESOURCE_TYPE_UNUSABLE; else if(fileType == EXTENSION_TYPE_COLLADA) return RESOURCE_TYPE_UNUSABLE; else if(fileType == EXTENSION_TYPE_BLEND) return RESOURCE_TYPE_UNUSABLE; else if(fileType == EXTENSION_TYPE_ANGELSCRIPT) return RESOURCE_TYPE_SCRIPTFILE; else if(fileType == EXTENSION_TYPE_LUASCRIPT) return RESOURCE_TYPE_SCRIPTFILE; else if(fileType == EXTENSION_TYPE_HLSL) return RESOURCE_TYPE_UNUSABLE; else if(fileType == EXTENSION_TYPE_GLSL) return RESOURCE_TYPE_UNUSABLE; else if(fileType == EXTENSION_TYPE_FRAGMENTSHADER) return RESOURCE_TYPE_UNUSABLE; else if(fileType == EXTENSION_TYPE_VERTEXSHADER) return RESOURCE_TYPE_UNUSABLE; else if(fileType == EXTENSION_TYPE_HTML) return RESOURCE_TYPE_UNUSABLE; return RESOURCE_TYPE_UNKNOWN; } bool GetExtensionType(String path, StringHash &out fileType) { StringHash type = StringHash(GetExtension(path)); if (type == EXTENSION_TYPE_TTF) fileType = EXTENSION_TYPE_TTF; else if (type == EXTENSION_TYPE_OTF) fileType = EXTENSION_TYPE_OTF; else if (type == EXTENSION_TYPE_OGG) fileType = EXTENSION_TYPE_OGG; else if(type == EXTENSION_TYPE_WAV) fileType = EXTENSION_TYPE_WAV; else if(type == EXTENSION_TYPE_DDS) fileType = EXTENSION_TYPE_DDS; else if(type == EXTENSION_TYPE_PNG) fileType = EXTENSION_TYPE_PNG; else if(type == EXTENSION_TYPE_JPG) fileType = EXTENSION_TYPE_JPG; else if(type == EXTENSION_TYPE_JPEG) fileType = EXTENSION_TYPE_JPEG; else if(type == EXTENSION_TYPE_BMP) fileType = EXTENSION_TYPE_BMP; else if(type == EXTENSION_TYPE_TGA) fileType = EXTENSION_TYPE_TGA; else if(type == EXTENSION_TYPE_KTX) fileType = EXTENSION_TYPE_KTX; else if(type == EXTENSION_TYPE_PVR) fileType = EXTENSION_TYPE_PVR; else if(type == EXTENSION_TYPE_OBJ) fileType = EXTENSION_TYPE_OBJ; else if(type == EXTENSION_TYPE_FBX) fileType = EXTENSION_TYPE_FBX; else if(type == EXTENSION_TYPE_COLLADA) fileType = EXTENSION_TYPE_COLLADA; else if(type == EXTENSION_TYPE_BLEND) fileType = EXTENSION_TYPE_BLEND; else if(type == EXTENSION_TYPE_ANGELSCRIPT) fileType = EXTENSION_TYPE_ANGELSCRIPT; else if(type == EXTENSION_TYPE_LUASCRIPT) fileType = EXTENSION_TYPE_LUASCRIPT; else if(type == EXTENSION_TYPE_HLSL) fileType = EXTENSION_TYPE_HLSL; else if(type == EXTENSION_TYPE_GLSL) fileType = EXTENSION_TYPE_GLSL; else if(type == EXTENSION_TYPE_FRAGMENTSHADER) fileType = EXTENSION_TYPE_FRAGMENTSHADER; else if(type == EXTENSION_TYPE_VERTEXSHADER) fileType = EXTENSION_TYPE_VERTEXSHADER; else if(type == EXTENSION_TYPE_HTML) fileType = EXTENSION_TYPE_HTML; else return false; return true; } bool GetBinaryType(String path, StringHash &out fileType, bool useCache = false) { StringHash type; if (useCache) { File@ file = cache.GetFile(path); if (file is null) return false; if (file.size == 0) return false; type = StringHash(file.ReadFileID()); } else { File@ file = File(); if (!file.Open(path)) return false; if (file.size == 0) return false; type = StringHash(file.ReadFileID()); } if (type == BINARY_TYPE_SCENE) fileType = BINARY_TYPE_SCENE; else if (type == BINARY_TYPE_PACKAGE) fileType = BINARY_TYPE_PACKAGE; else if (type == BINARY_TYPE_COMPRESSED_PACKAGE) fileType = BINARY_TYPE_COMPRESSED_PACKAGE; else if (type == BINARY_TYPE_ANGLESCRIPT) fileType = BINARY_TYPE_ANGLESCRIPT; else if (type == BINARY_TYPE_MODEL) fileType = BINARY_TYPE_MODEL; else if (type == BINARY_TYPE_SHADER) fileType = BINARY_TYPE_SHADER; else if (type == BINARY_TYPE_ANIMATION) fileType = BINARY_TYPE_ANIMATION; else return false; return true; } bool GetXmlType(String path, StringHash &out fileType, bool useCache = false) { String extension = GetExtension(path); if (extension == "".txt"" || extension == "".json"" || extension == "".icns"" || extension == "".atlas"") return false; String name; if (useCache) { XMLFile@ xml = cache.GetResource(""XMLFile"", path); if (xml is null) return false; name = xml.root.name; } else { File@ file = File(); if (!file.Open(path)) return false; if (file.size == 0) return false; XMLFile@ xml = XMLFile(); if (xml.Load(file)) name = xml.root.name; else return false; } bool found = false; if (!name.empty) { found = true; StringHash type = StringHash(name); if (type == XML_TYPE_SCENE) fileType = XML_TYPE_SCENE; else if (type == XML_TYPE_NODE) fileType = XML_TYPE_NODE; else if(type == XML_TYPE_MATERIAL) fileType = XML_TYPE_MATERIAL; else if(type == XML_TYPE_TECHNIQUE) fileType = XML_TYPE_TECHNIQUE; else if(type == XML_TYPE_PARTICLEEFFECT) fileType = XML_TYPE_PARTICLEEFFECT; else if(type == XML_TYPE_PARTICLEEMITTER) fileType = XML_TYPE_PARTICLEEMITTER; else if(type == XML_TYPE_TEXTURE) fileType = XML_TYPE_TEXTURE; else if(type == XML_TYPE_ELEMENT) fileType = XML_TYPE_ELEMENT; else if(type == XML_TYPE_ELEMENTS) fileType = XML_TYPE_ELEMENTS; else if (type == XML_TYPE_ANIMATION_SETTINGS) fileType = XML_TYPE_ANIMATION_SETTINGS; else if (type == XML_TYPE_RENDERPATH) fileType = XML_TYPE_RENDERPATH; else if (type == XML_TYPE_TEXTURE_ATLAS) fileType = XML_TYPE_TEXTURE_ATLAS; else if (type == XML_TYPE_2D_PARTICLE_EFFECT) fileType = XML_TYPE_2D_PARTICLE_EFFECT; else if (type == XML_TYPE_TEXTURE_3D) fileType = XML_TYPE_TEXTURE_3D; else if (type == XML_TYPE_CUBEMAP) fileType = XML_TYPE_CUBEMAP; else if (type == XML_TYPE_SPRITER_DATA) fileType = XML_TYPE_SPRITER_DATA; else found = false; } return found; } String ResourceTypeName(int resourceType) { if (resourceType == RESOURCE_TYPE_UNUSABLE) return ""Unusable""; else if (resourceType == RESOURCE_TYPE_UNKNOWN) return ""Unknown""; else if (resourceType == RESOURCE_TYPE_NOTSET) return ""Uninitialized""; else if (resourceType == RESOURCE_TYPE_SCENE) return ""Scene""; else if (resourceType == RESOURCE_TYPE_SCRIPTFILE) return ""Script File""; else if (resourceType == RESOURCE_TYPE_MODEL) return ""Model""; else if (resourceType == RESOURCE_TYPE_MATERIAL) return ""Material""; else if (resourceType == RESOURCE_TYPE_ANIMATION) return ""Animation""; else if (resourceType == RESOURCE_TYPE_IMAGE) return ""Image""; else if (resourceType == RESOURCE_TYPE_SOUND) return ""Sound""; else if (resourceType == RESOURCE_TYPE_TEXTURE) return ""Texture""; else if (resourceType == RESOURCE_TYPE_FONT) return ""Font""; else if (resourceType == RESOURCE_TYPE_PREFAB) return ""Prefab""; else if (resourceType == RESOURCE_TYPE_TECHNIQUE) return ""Render Technique""; else if (resourceType == RESOURCE_TYPE_PARTICLEEFFECT) return ""Particle Effect""; else if (resourceType == RESOURCE_TYPE_PARTICLEEMITTER) return ""Particle Emitter""; else if (resourceType == RESOURCE_TYPE_UIELEMENT) return ""UI Element""; else if (resourceType == RESOURCE_TYPE_UIELEMENTS) return ""UI Elements""; else if (resourceType == RESOURCE_TYPE_ANIMATION_SETTINGS) return ""Animation Settings""; else if (resourceType == RESOURCE_TYPE_RENDERPATH) return ""Render Path""; else if (resourceType == RESOURCE_TYPE_TEXTURE_ATLAS) return ""Texture Atlas""; else if (resourceType == RESOURCE_TYPE_2D_PARTICLE_EFFECT) return ""2D Particle Effect""; else if (resourceType == RESOURCE_TYPE_TEXTURE_3D) return ""Texture 3D""; else if (resourceType == RESOURCE_TYPE_CUBEMAP) return ""Cubemap""; else if (resourceType == RESOURCE_TYPE_2D_ANIMATION_SET) return ""2D Animation Set""; else return """"; } class BrowserDir { uint id; String resourceKey; String name; Array children; Array files; BrowserDir(String path_) { resourceKey = path_; String parent = GetParentPath(path_); name = path_; name.Replace(parent, """"); id = browserDirIndex++; } int opCmp(BrowserDir@ b) { return name.opCmp(b.name); } BrowserFile@ AddFile(String name, uint resourceSourceIndex, uint sourceType) { String path = resourceKey + ""/"" + name; BrowserFile@ file = BrowserFile(path, resourceSourceIndex, sourceType); files.Push(file); return file; } } class BrowserFile { uint id; uint resourceSourceIndex; String resourceKey; String name; String fullname; String extension; StringHash fileType; int resourceType = 0; int sourceType = 0; int sortScore = 0; WeakHandle browserFileListRow; BrowserFile(String path_, uint resourceSourceIndex_, int sourceType_) { sourceType = sourceType_; resourceSourceIndex = resourceSourceIndex_; resourceKey = path_; name = GetFileName(path_); extension = GetExtension(path_); fullname = GetFileNameAndExtension(path_); id = browserFileIndex++; } int opCmp(BrowserFile@ b) { if (browserSearchSortMode == 1) return fullname.opCmp(b.fullname); else return sortScore - b.sortScore; } String GetResourceSource() { if (sourceType == BROWSER_FILE_SOURCE_RESOURCE_DIR) return cache.resourceDirs[resourceSourceIndex]; else return ""Unknown""; } String GetFullPath() { return String(cache.resourceDirs[resourceSourceIndex] + resourceKey); } String GetPath() { return resourceKey; } void DetermainResourceType() { resourceType = GetResourceType(GetFullPath(), fileType, false); Text@ browserFileListRow_ = browserFileListRow.Get(); if (browserFileListRow_ !is null) { InitializeBrowserFileListRow(browserFileListRow_, this); } } String ResourceTypeName() { return ::ResourceTypeName(resourceType); } void FileChanged() { if (!fileSystem.FileExists(GetFullPath())) { } else { } } } void CreateResourcePreview(String path, Node@ previewNode) { resourceBrowserPreview.autoUpdate = false; int resourceType = GetResourceType(path); if (resourceType > 0) { File file; file.Open(path); if (resourceType == RESOURCE_TYPE_MODEL) { Model@ model = Model(); if (model.Load(file)) { StaticModel@ staticModel = previewNode.CreateComponent(""StaticModel""); staticModel.model = model; return; } } else if (resourceType == RESOURCE_TYPE_MATERIAL) { Material@ material = Material(); if (material.Load(file)) { StaticModel@ staticModel = previewNode.CreateComponent(""StaticModel""); staticModel.model = cache.GetResource(""Model"", ""Models/Sphere.mdl""); staticModel.material = material; return; } } else if (resourceType == RESOURCE_TYPE_IMAGE) { Image@ image = Image(); if (image.Load(file)) { StaticModel@ staticModel = previewNode.CreateComponent(""StaticModel""); staticModel.model = cache.GetResource(""Model"", ""Models/Editor/ImagePlane.mdl""); Material@ material = cache.GetResource(""Material"", ""Materials/Editor/TexturedUnlit.xml""); Texture2D@ texture = Texture2D(); texture.SetData(@image, true); material.textures[0] = texture; staticModel.material = material; return; } } else if (resourceType == RESOURCE_TYPE_PREFAB) { if (GetExtension(path) == "".xml"") { XMLFile xmlFile; if(xmlFile.Load(file)) if(previewNode.LoadXML(xmlFile.root, true) && (previewNode.GetComponents(""StaticModel"", true).length > 0 || previewNode.GetComponents(""AnimatedModel"", true).length > 0)) { return; } } else if(previewNode.Load(file, true) && (previewNode.GetComponents(""StaticModel"", true).length > 0 || previewNode.GetComponents(""AnimatedModel"", true).length > 0)) return; previewNode.RemoveAllChildren(); previewNode.RemoveAllComponents(); } else if (resourceType == RESOURCE_TYPE_PARTICLEEFFECT) { ParticleEffect@ particleEffect = ParticleEffect(); if (particleEffect.Load(file)) { ParticleEmitter@ particleEmitter = previewNode.CreateComponent(""ParticleEmitter""); particleEmitter.effect = particleEffect; particleEffect.activeTime = 0.0; particleEmitter.Reset(); resourceBrowserPreview.autoUpdate = true; return; } } } StaticModel@ staticModel = previewNode.CreateComponent(""StaticModel""); staticModel.model = cache.GetResource(""Model"", ""Models/Editor/ImagePlane.mdl""); Material@ material = cache.GetResource(""Material"", ""Materials/Editor/TexturedUnlit.xml""); Texture2D@ texture = Texture2D(); Image@ noPreviewImage = cache.GetResource(""Image"", ""Textures/Editor/NoPreviewAvailable.png""); texture.SetData(noPreviewImage, false); material.textures[0] = texture; staticModel.material = material; return; } void RotateResourceBrowserPreview(StringHash eventType, VariantMap& eventData) { int elemX = eventData[""ElementX""].GetInt(); int elemY = eventData[""ElementY""].GetInt(); if (resourceBrowserPreview.height > 0 && resourceBrowserPreview.width > 0) { float yaw = ((resourceBrowserPreview.height / 2) - elemY) * (90.0 / resourceBrowserPreview.height); float pitch = ((resourceBrowserPreview.width / 2) - elemX) * (90.0 / resourceBrowserPreview.width); resourcePreviewNode.rotation = resourcePreviewNode.rotation.Slerp(Quaternion(yaw, pitch, 0), 0.1); RefreshBrowserPreview(); } } void RefreshBrowserPreview() { resourceBrowserPreview.QueueUpdate(); } class ResourceType { int id; String name; ResourceType(int id_, String name_) { id = id_; name = name_; } int opCmp(ResourceType@ b) { return name.opCmp(b.name); } } ",12478,False,2431.0702147883358,median "/* IconMenu.ino This is an interactive demo and requires ""next"", ""prev"" and ""select"" button. Minimum height of the display should be 64. Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8g2lib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Frame Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_F_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1322_NHD_256X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_MIDAS_128X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_WS_128X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_F_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_F_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_F u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_F u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_F_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_F_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7565_EA_DOGM128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LX12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_F_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_F_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_F_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_F u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FG with GND //U8G2_SED1330_240X128_F_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // A0 is dc pin! //U8G2_RA8835_NHD_240X128_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1604_JLX19264_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_F_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_F_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, DOGXL240 Test Board //U8G2_UC1611_EW50850_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1638_160X128_F_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_MAX7219_64X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); //U8G2_MAX7219_32X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); //U8G2_MAX7219_8X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); //U8G2_LS013B7DH03_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_F_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list void setup(void) { // DOGS102 Shield (http://shieldlist.org/controlconnection/dogs102) // u8g2.begin(/* menu_select_pin= */ 5, /* menu_next_pin= */ 4, /* menu_prev_pin= */ 2, /* menu_home_pin= */ 3); // DOGM128 Shield (http://shieldlist.org/schmelle2/dogm128) + DOGXL160 Shield // u8g2.begin(/* menu_select_pin= */ 2, /* menu_next_pin= */ 3, /* menu_prev_pin= */ 7, /* menu_home_pin= */ 8); // MKR Zero Test Board u8g2.begin(/*Select=*/ 0, /*Right/Next=*/ 1, /*Left/Prev=*/ 2, /*Up=*/ 4, /*Down=*/ 3, /*Home/Cancel=*/ A6); // Arduboy //u8g2.begin(/*Select=*/ A0, /*Right/Next=*/ 5, /*Left/Prev=*/ 9, /*Up=*/ 8, /*Down=*/ 10, /*Home/Cancel=*/ A1); // Arduboy DevKit //u8g2.begin(/*Select=*/ 7, /*Right/Next=*/ A1, /*Left/Prev=*/ A2, /*Up=*/ A0, /*Down=*/ A3, /*Home/Cancel=*/ 8); // Arduboy 10 (Production) u8g2.setFont(u8g2_font_6x12_tr); } struct menu_entry_type { const uint8_t *font; uint16_t icon; const char *name; }; struct menu_state { int16_t menu_start; /* in pixel */ int16_t frame_position; /* in pixel */ uint8_t position; /* position, array index */ }; /* Icon configuration Width and height must match the icon font size GAP: Space between the icons BGAP: Gap between the display border and the cursor. */ #define ICON_WIDTH 32 #define ICON_HEIGHT 32 #define ICON_GAP 4 #define ICON_BGAP 16 #define ICON_Y 32+ ICON_GAP struct menu_entry_type menu_entry_list[] = { { u8g2_font_open_iconic_embedded_4x_t, 65, ""Clock Setup""}, { u8g2_font_open_iconic_embedded_4x_t, 66, ""Gear Game""}, { u8g2_font_open_iconic_embedded_4x_t, 67, ""Flash Light""}, { u8g2_font_open_iconic_embedded_4x_t, 68, ""Home""}, { u8g2_font_open_iconic_embedded_4x_t, 72, ""Configuration""}, { NULL, 0, NULL } }; void draw(struct menu_state *state) { int16_t x; uint8_t i; x = state->menu_start; i = 0; while( menu_entry_list[i].icon > 0 ) { if ( x >= -ICON_WIDTH && x < u8g2.getDisplayWidth() ) { u8g2.setFont(menu_entry_list[i].font); u8g2.drawGlyph(x, ICON_Y, menu_entry_list[i].icon ); } i++; x += ICON_WIDTH + ICON_GAP; } u8g2.drawFrame(state->frame_position-1, ICON_Y-ICON_HEIGHT-1, ICON_WIDTH+2, ICON_WIDTH+2); u8g2.drawFrame(state->frame_position-2, ICON_Y-ICON_HEIGHT-2, ICON_WIDTH+4, ICON_WIDTH+4); u8g2.drawFrame(state->frame_position-3, ICON_Y-ICON_HEIGHT-3, ICON_WIDTH+6, ICON_WIDTH+6); } void to_right(struct menu_state *state) { if ( menu_entry_list[state->position+1].font != NULL ) { if ( (int16_t)state->frame_position+ 2*(int16_t)ICON_WIDTH + (int16_t)ICON_BGAP < (int16_t)u8g2.getDisplayWidth() ) { state->position++; state->frame_position += ICON_WIDTH + (int16_t)ICON_GAP; } else { state->position++; state->frame_position = (int16_t)u8g2.getDisplayWidth() - (int16_t)ICON_WIDTH - (int16_t)ICON_BGAP; state->menu_start = state->frame_position - state->position*((int16_t)ICON_WIDTH + (int16_t)ICON_GAP); } } } void to_left(struct menu_state *state) { if ( state->position > 0 ) { if ( (int16_t)state->frame_position >= (int16_t)ICON_BGAP+(int16_t)ICON_WIDTH+ (int16_t)ICON_GAP ) { state->position--; state->frame_position -= ICON_WIDTH + (int16_t)ICON_GAP; } else { state->position--; state->frame_position = ICON_BGAP; state->menu_start = state->frame_position - state->position*((int16_t)ICON_WIDTH + (int16_t)ICON_GAP); } } } uint8_t towards_int16(int16_t *current, int16_t dest) { if ( *current < dest ) { (*current)++; return 1; } else if ( *current > dest ) { (*current)--; return 1; } return 0; } uint8_t towards(struct menu_state *current, struct menu_state *destination) { uint8_t r = 0; r |= towards_int16( &(current->frame_position), destination->frame_position); r |= towards_int16( &(current->frame_position), destination->frame_position); r |= towards_int16( &(current->menu_start), destination->menu_start); r |= towards_int16( &(current->menu_start), destination->menu_start); return r; } struct menu_state current_state = { ICON_BGAP, ICON_BGAP, 0 }; struct menu_state destination_state = { ICON_BGAP, ICON_BGAP, 0 }; void loop(void) { int8_t event; do { u8g2.clearBuffer(); draw(¤t_state); u8g2.setFont(u8g2_font_helvB10_tr); u8g2.setCursor((u8g2.getDisplayWidth()-u8g2.getStrWidth(menu_entry_list[destination_state.position].name))/2,u8g2.getDisplayHeight()-5); u8g2.print(menu_entry_list[destination_state.position].name); u8g2.sendBuffer(); delay(10); event = u8g2.getMenuEvent(); if ( event == U8X8_MSG_GPIO_MENU_NEXT ) to_right(&destination_state); if ( event == U8X8_MSG_GPIO_MENU_PREV ) to_left(&destination_state); if ( event == U8X8_MSG_GPIO_MENU_SELECT ) { u8g2.setFont(u8g2_font_helvB10_tr); u8g2.userInterfaceMessage(""Selection:"", menu_entry_list[destination_state.position].name, """", "" Ok ""); } } while ( towards(¤t_state, &destination_state) ); } ",16368,True,4370.697759236356,median "/* ScrollingText.ino This will scroll text on the display. Enable U8g2 16 bit mode (see FAQ) for larger text! Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U82glib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1306_72X40_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_WS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7567_HEM6432_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_IST7920_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_IST7920_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_DEM240064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1617_JLX128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1617_JLX128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list // This example shows a scrolling text. // If U8G2_16BIT is not set (default), then the pixel width of the text must be lesser than 128 // If U8G2_16BIT is set, then the pixel width an be up to 32000 u8g2_uint_t offset; // current offset for the scrolling text u8g2_uint_t width; // pixel width of the scrolling text (must be lesser than 128 unless U8G2_16BIT is defined const char *text = ""U8g2 ""; // scroll this text from right to left void setup(void) { /* U8g2 Project: SSD1306 Test Board */ //pinMode(10, OUTPUT); //pinMode(9, OUTPUT); //digitalWrite(10, 0); //digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); u8g2.begin(); u8g2.setFont(u8g2_font_inb30_mr); // set the target font to calculate the pixel width width = u8g2.getUTF8Width(text); // calculate the pixel width of the text u8g2.setFontMode(0); // enable transparent mode, which is faster } void loop(void) { u8g2_uint_t x; u8g2.firstPage(); do { // draw the scrolling text at current offset x = offset; u8g2.setFont(u8g2_font_inb30_mr); // set the target font do { // repeated drawing of the scrolling text... u8g2.drawUTF8(x, 30, text); // draw the scolling text x += width; // add the pixel width of the scrolling text } while( x < u8g2.getDisplayWidth() ); // draw again until the complete display is filled u8g2.setFont(u8g2_font_inb16_mr); // draw the current pixel width u8g2.setCursor(0, 58); u8g2.print(width); // this value must be lesser than 128 unless U8G2_16BIT is set } while ( u8g2.nextPage() ); offset-=1; // scroll by one pixel if ( (u8g2_uint_t)offset < (u8g2_uint_t)-width ) offset = 0; // start over again delay(10); // do some small delay } ",16275,True,4935.0773880166125,median "#include ""Arduino.h"" #include #include #include #include /* * Utilizing FastLED painter libary and some animations from Damian Schneider. */ /* * LED animation members, constants, headers */ const int duration = 1000; //number of loops to run each animation for #if FASTLED_VERSION < 3001000 #error ""Requires FastLED 3.1 or later; check github for latest code."" #endif // Fixed definitions cannot change on the fly. #define LED_DT 4 // Data pin to connect to the strip. For APA strips this generally the GREEN wire. #define LED_CK 5 // For APA strips this generally the YELLOW wire. #define COLOR_ORDER BGR // Are they RGB, GRB or what?? #define LED_TYPE APA102 // Don't forget to change LEDS.addLeds #define NUM_LEDS 144 //Number of LEDs on the strip // Initialize changeable global variables. uint8_t max_bright = 128; // Overall brightness definition. It can be changed on the fly. struct CRGB leds[NUM_LEDS]; //create one canvas and one brush with global scope FastLEDPainterCanvas pixelcanvas = FastLEDPainterCanvas(NUM_LEDS); //create canvas, linked to the FastLED library (canvas must be created before the brush) FastLEDPainterBrush pixelbrush = FastLEDPainterBrush(&pixelcanvas); //crete brush, linked to the canvas to paint to // FOR BOUNCY BALLS ANIMATION //create additional brushes, painting on the same canvas as the globally defined brush FastLEDPainterBrush pixelbrushBB2 = FastLEDPainterBrush(&pixelcanvas); //crete brush, linked to the canvas to paint to FastLEDPainterBrush pixelbrushBB3 = FastLEDPainterBrush(&pixelcanvas); //crete brush, linked to the canvas to paint to /* * I2C members, constants and headers */ #define INTERRUPT_PIN 2 // use pin 2 on Arduino Uno & most boards #define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6) #include NXPMotionSense imu; NXPSensorFusion filter; #include ""I2Cdev.h"" #include ""MPU6050_6Axis_MotionApps20.h"" //#include ""MPU6050.h"" // not necessary if using MotionApps include file // Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation // is used in I2Cdev.h #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include ""Wire.h"" #endif // default I2C address is 0x68 MPU6050 mpu; // uncomment ""OUTPUT_READABLE_YAWPITCHROLL"" if you want to see the yaw/ // pitch/roll angles (in degrees) calculated from the quaternions coming // from the FIFO. Note this also requires gravity vector calculations. // Also note that yaw/pitch/roll angles suffer from gimbal lock (for // more info, see: http://en.wikipedia.org/wiki/Gimbal_lock) #define OUTPUT_READABLE_YAWPITCHROLL const bool DEBUG_OUTPUT = true; const bool YAW_ANIMATION_CONTROL = false; const uint8_t DIAL_SENSITIVITY = 35; const uint8_t ADDRESS_ANIMATION_NUM = 0; const uint8_t ANIMATION_COUNT = 4; bool blinkState = false; uint8_t YAW = 2; uint8_t ROLL = 1; uint8_t speedController = ROLL; uint8_t secondaryController = YAW; bool dynamiclyAssignMotionControls = false; // MPU control/status vars bool dmpReady = false; // set true if DMP init was successful uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU uint8_t devStatus; // return status after each device operation (0 = success, !0 = error) uint16_t packetSize; // expected DMP packet size (default is 42 bytes) uint16_t fifoCount; // count of all bytes currently in FIFO uint8_t fifoBuffer[64]; // FIFO storage buffer // orientation/motion vars Quaternion qc; // [w, x, y, z] quaternion container VectorInt16 aa; // [x, y, z] accel sensor measurements VectorInt16 aaReal; // [x, y, z] gravity-free accel sensor measurements VectorInt16 aaWorld; // [x, y, z] world-frame accel sensor measurements VectorFloat gravity; // [x, y, z] gravity vector float euler[3]; // [psi, theta, phi] Euler angle container float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector // CircularBuffer rollHistory; unsigned long time = 0; float roll_rate = 0.0; // roll rate float old_roll_rate = 0.0; // roll rate const float ROLL_THRESHOLD = 15.0; bool spinning_animation = false; uint8_t randomShow; uint8_t animationNumber; uint16_t programNotch; static signed int speed = 1; static signed int lastSpeed = speed; byte eprom; //static unsigned int hue = 0; //color hue to set to brush CHSV brushcolor; //HSV color definition // ================================================================ // === INTERRUPT DETECTION ROUTINE === // ================================================================ volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; } void setup() { delay(1000); // sanity check delay // put your setup code here, to run once: // LEDS.addLeds(leds, NUM_LEDS); // Use this for WS2801 or APA102 FastLED.addLeds(leds, NUM_LEDS); pinMode(7, OUTPUT); digitalWrite(7, HIGH); //setupI2C(); // initI2C(); // readMpu(); time = millis(); setupPropShield(); readPropShield(); setupLedAnimations(); randomShow = random(10); Serial.print(""random number is:""); Serial.print(randomShow); Serial.print(""\\n""); // reading EEPROM persisted animation number animationNumber = EEPROM.read(ADDRESS_ANIMATION_NUM); Serial.print(""ANIMATION EEPROM :""); Serial.print(animationNumber); Serial.print(""\\n""); if(!YAW_ANIMATION_CONTROL) saveAnimationNum((animationNumber + 1) % ANIMATION_COUNT); if(DEBUG_OUTPUT) delay(200); //delay so serial interface on teensy can be created (it's a virtual interface) if(dynamiclyAssignMotionControls) initDynamicControlsDuringBatteryCheck(); else batteryCheck(); } // Animation void blink(float voltage) { int blinkCount = 0; if(voltage > 4.2) blinkCount = 5; else if(voltage > 4.0) blinkCount = 4; else if(voltage > 3.8) blinkCount = 3; else if(voltage > 3.6) blinkCount = 2; else if(voltage > 3.4) blinkCount = 1; for(int i = 0; i < blinkCount; i++) { pixelbrush.setFadeSpeed(90); pixelbrush.setFadein(false); //brightness will fade-in if set to true pixelbrush.setFadeout(true); pixelbrush.setBounce(false); pixelbrush.setSpeed(0); //brush moving speed brushcolor.s = 255; //full saturation int brightness = 255; brushcolor.v = brightness; //random (peak) brighness pixelbrush.setColor(brushcolor); //set new color to the bursh FastLED.clear(); FastLED.show(); delay(200); pixelbrush.paint(); //paint the brush to the canvas (and update the brush, i.e. move it a little) pixelcanvas.transfer(); //transfer (add) the canvas to the FastLED FastLED.show(); delay(200); } } void batteryCheck() { int sensorValue = analogRead(A0); //read the A0 pin value float voltage = sensorValue * (5.00 / 1600.00) * 2; //convert the value to a true voltage. Serial.print(""voltage = ""); Serial.print(voltage); Serial.println("" V""); blink(voltage); //blinks indicating approximate battery level } // Allows one to orient the stave in position one would like to have as primary speed controller // during the battery check led animation. void initDynamicControlsDuringBatteryCheck() { int sensorValue = analogRead(A0); //read the A0 pin value float voltage = sensorValue * (5.00 / 1600.00) * 2; //convert the value to a true voltage. Serial.print(""voltage = ""); Serial.print(voltage); Serial.println("" V""); // Part 1 take initial readings readMpu(); //throw out first one. readMpu(); float yaw = ypr[0] * 180/M_PI; float pitch = ypr[1] * 180/M_PI; float roll = ypr[2] * 180/M_PI; blink(voltage); //blinks indicating approximate battery level // Part 2 take final readings post battery animation readMpu(); float yaw_later = ypr[0] * 180/M_PI; float pitch_later = ypr[1] * 180/M_PI; float roll_later = ypr[2] * 180/M_PI; // the one with the biggest difference is now the main speed controller float y_diff = abs(yaw - yaw_later); float r_diff = abs(roll - roll_later); if(DEBUG_OUTPUT) { Serial.print(""yaw diff: ""); Serial.print(y_diff); Serial.print("" roll diff: ""); Serial.println(r_diff); } if(y_diff > r_diff) speedController = YAW; else speedController = ROLL; if(DEBUG_OUTPUT) { if(speedController == ROLL) Serial.println(""speedController: ROLL""); else if(speedController == YAW) Serial.println(""speedController: YAW""); } } // ================================================================ // === INITIAL I2C SETUP === // ================================================================ void setupI2C() { // join I2C bus (I2Cdev library doesn't do this automatically) #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin(); Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having compilation difficulties #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif // initialize serial communication // (115200 chosen because it is required for Teapot Demo output, but it's // really up to you depending on your project) Serial.begin(115200); while (!Serial); // wait for Leonardo enumeration, others continue immediately // NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Ardunio // Pro Mini running at 3.3v, cannot handle this baud rate reliably due to // the baud timing being too misaligned with processor ticks. You must use // 38400 or slower in these cases, or use some kind of external separate // crystal solution for the UART timer. // initialize device Serial.println(F(""Initializing I2C devices..."")); mpu.initialize(); pinMode(INTERRUPT_PIN, INPUT); // verify connection Serial.println(F(""Testing device connections..."")); Serial.println(mpu.testConnection() ? F(""MPU6050 connection successful"") : F(""MPU6050 connection failed"")); // wait for ready Serial.println(F(""\\nSend any character to begin DMP programming and demo: "")); // while (Serial.available() && Serial.read()); // empty buffer // while (!Serial.available()); // wait for data // while (Serial.available() && Serial.read()); // empty buffer again // load and configure the DMP Serial.println(F(""Initializing DMP..."")); devStatus = mpu.dmpInitialize(); // supply your own gyro offsets here, scaled for min sensitivity mpu.setXGyroOffset(220); mpu.setYGyroOffset(76); mpu.setZGyroOffset(-85); mpu.setZAccelOffset(1788); // 1688 factory default for my test chip // make sure it worked (returns 0 if so) if (devStatus == 0) { // turn on the DMP, now that it's ready Serial.println(F(""Enabling DMP..."")); mpu.setDMPEnabled(true); // enable Arduino interrupt detection Serial.println(F(""Enabling interrupt detection (Arduino external interrupt 0)..."")); //attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), dmpDataReady, RISING); //mpuIntStatus = mpu.getIntStatus(); mpuIntStatus = 1; // set our DMP Ready flag so the main loop() function knows it's okay to use it Serial.println(F(""DMP ready! Waiting for first interrupt..."")); dmpReady = true; // get expected DMP packet size for later comparison packetSize = mpu.dmpGetFIFOPacketSize(); } else { // ERROR! // 1 = initial memory load failed // 2 = DMP configuration updates failed // (if it's going to break, usually the code will be 1) Serial.print(F(""DMP Initialization failed (code "")); Serial.print(devStatus); Serial.println(F("")"")); } Serial.print(F(""after the interupt wait..."")); // configure LED for output pinMode(LED_PIN, OUTPUT); } void setupLedAnimations() { randomSeed(analogRead(0)); //new random seed FastLED.show(); Serial.begin(115200); Serial.println("" ""); Serial.println(""Ray's rave stave begin""); //check if ram allocation of brushes and canvases was successful (painting will not work if unsuccessful, program should still run though) //this check is optional but helps to check if something does not work, especially on low ram chips like the Arduino Uno if (pixelcanvas.isvalid() == false) Serial.println(""canvas allocation problem""); else Serial.println(""canvas allocation ok""); if (pixelbrush.isvalid() == false) Serial.println(""brush allocation problem""); else Serial.println(""brush allocation ok""); brushcolor.h = random(255); //random color brushcolor.s = 255; //full saturation brushcolor.v = 255; //full brightness } unsigned long loopcounter; //count the loops, switch to next animation after a while bool initialized = false; //initialize the canvas & brushes in each loop when zero void loop() { //ledAnimationBundle(); //blink(); doUserInput(); // side steps the random show choice! FYI loops on itself if( randomShow >7) { doUserInput(); } else if(randomShow>=4 && randomShow<=6) { doSlowAnimations(); } else { ledAnimationBundle(); } } void doSlowAnimations() { while(true) { initialized = false; twinkleStars(); initialized = false; hueDemo(); initialized = false; twoBrushColorMixing(); } } void doUserInput() { // initI2C(); // readMpu(); setupPropShield(); readPropShield(); if(YAW_ANIMATION_CONTROL) { float yaw = ypr[0] * 180/M_PI; float pitch = ypr[1] * 180/M_PI; float roll = ypr[2] * 180/M_PI; programNotch = abs(yaw); Serial.print(""programNotch: ""); Serial.print(programNotch); } while(true) { doLeds(); } } void doLeds() { initialized = false; // readMpu(); readPropShield(); float yaw = ypr[0] * 180/M_PI; float pitch = ypr[1] * 180/M_PI; float roll = ypr[2] * 180/M_PI; if(YAW_ANIMATION_CONTROL) { int programNotchNow = abs(yaw); if(abs(programNotchNow - programNotch) > DIAL_SENSITIVITY) { programNotch = abs(yaw); animationNumber = (++animationNumber)%3; saveAnimationNum(animationNumber); if(DEBUG_OUTPUT) { Serial.print(""new programNotch: ""); Serial.print(programNotch); Serial.print("" new animationNumber: ""); Serial.print(animationNumber); } } } //raindbowPaint(); // bouncyBalls(); // initialized = false; //sparkler(); //twoBrushColorMixing(); if(DEBUG_OUTPUT) { // Serial.print(""\\nanimationNumber: ""); // Serial.print(animationNumber); // Serial.print("" ""); } // Dynamic user input animations if (animationNumber % ANIMATION_COUNT == 0) { dripRead(); } else if (animationNumber % ANIMATION_COUNT == 1) { rainbowPaintRead(); } else if (animationNumber % ANIMATION_COUNT == 2) { sparklerFireRead(10, false); } else { sparklerRead(); } // Static fire animations // if (animationNumber % ANIMATION_COUNT == 0) { // sparklerFireRead(10, false); // } // else if (animationNumber % ANIMATION_COUNT == 1) { // sparklerFireRead(10, true); // } // else if (animationNumber % ANIMATION_COUNT == 2) { // sparklerFireRead(125, false); // } // else { // sparklerFireRead(125, true); // } if(DEBUG_OUTPUT && YAW_ANIMATION_CONTROL) { Serial.print(""next programNotch [ ""); Serial.print(programNotch - DIAL_SENSITIVITY); Serial.print("" <-> ""); Serial.print(programNotch + DIAL_SENSITIVITY); Serial.print("" ]\\n""); } } void saveAnimationNum(int number) { EEPROM.write(ADDRESS_ANIMATION_NUM, number); } // Animation void dripRead() { // Serial.print(F(""in dripRead\\n"")); if (initialized == false) //initialize the brushes { initialized = true; pixelbrush.setFadeSpeed(90); pixelbrush.setFadein(false); //brightness will fade-in if set to true pixelbrush.setFadeout(true); pixelbrush.setBounce(false); } // float yaw = ypr[0] * 180/M_PI; // float pitch = ypr[1] * 180/M_PI; // float roll = ypr[2] * 180/M_PI; float yaw = ypr[0]; float pitch = ypr[1]; float roll = ypr[2]; updateSpeed(5); if(speed > 0 && lastSpeed < 0 || speed < 0 && lastSpeed > 0) { brushcolor.h = random(255); //random color } pixelbrush.setSpeed(speed); //brush moving speed brushcolor.s = 255; //full saturation // int brightness = 125 - abs(pitch) * 2.8; //TODO configure the brightness according the secondaryController global var int brightness = int(abs(yaw)) % 120; //TODO configure the brightness according the secondaryController global var brushcolor.v = brightness; //random (peak) brighness pixelbrush.setColor(brushcolor); //set new color to the bursh FastLED.clear(); pixelbrush.paint(); //paint the brush to the canvas (and update the brush, i.e. move it a little) pixelcanvas.transfer(); //transfer (add) the canvas to the FastLED if (DEBUG_OUTPUT) { printInfo(brightness); // Serial.print(""speed: ""); // Serial.print(speed); // if(speedController == ROLL) // Serial.println("" speedController: ROLL""); // else if(speedController == YAW) // Serial.println("" speedController: YAW""); // Serial.print(""\\nbrightness: ""); // Serial.print(brightness); // Serial.print(""\\n""); } FastLED.show(); } void printInfo(int brightness) { // char buf[10]; // sprintf(buf, ""speed %d"", speed) // Serial.println(buf); // Serial.print(""speed: ""); // Serial.print(speed); // Serial.print("" brightness: ""); // Serial.print(brightness); // if(speedController == ROLL) // Serial.print("" speedController: ROLL""); // else if(speedController == YAW) // Serial.println("" speedController: YAW""); // float roll, pitch, yaw; // roll = filter.getRoll(); // pitch = filter.getPitch(); // yaw = filter.getYaw(); // Serial.print("" yaw: ""); // Serial.print(yaw); // Serial.print("" pitch: ""); // Serial.print(pitch); // Serial.print("" roll: ""); // Serial.println(roll); // Serial.print(""\\n""); } void printInfo2(int brightness) { Serial.print(""speed: ""); Serial.print(speed); Serial.print("" brightness: ""); Serial.print(brightness); if(speedController == ROLL) Serial.print("" speedController: ROLL""); else if(speedController == YAW) Serial.println("" speedController: YAW""); float roll, pitch, yaw; roll = filter.getRoll(); pitch = filter.getPitch(); yaw = filter.getYaw(); Serial.print("" yaw: ""); Serial.print(yaw); Serial.print("" pitch: ""); Serial.print(pitch); Serial.print("" roll: ""); Serial.println(roll); Serial.print(""\\n""); } void ledAnimationBundle() { while(true) { initialized = false; rainbowPaint(); initialized = false; sparkler(); // fast shooting white balls initialized = false; twinkleStars(); // not good for motion control initialized = false; chaser(); // low surface area dark chaser initialized = false; hueDemo(); //maybe brightness? initialized = false; speedTrails(); //great for motion roll initialized = false; bouncyBalls(); initialized = false; twoBrushColorMixing(); } } void rainbowBlink() { Serial.println(F(""rainbow blink"")); //the brush moves along the strip, leaving a colorful rainbow trail for(loopcounter = 0; loopcounter<100; loopcounter++) { static unsigned int hue = 0; //color hue to set to brush //CHSV brushcolor; //HSV color definition if (initialized == false) //initialize the brushes { initialized = true; pixelbrush.setSpeed(random(200) + 200); //brush moving speed pixelbrush.setFadeSpeed(90); pixelbrush.setFadein(false); //brightness will fade-in if set to true pixelbrush.setFadeout(true); pixelbrush.setBounce(false); } hue++; brushcolor.h = hue / 3; //divide by 3 to slow down color fading brushcolor.s = 255; //full saturation brushcolor.v = 125; //full brightness pixelbrush.setColor(brushcolor); //set new color to the bursh FastLED.clear(); pixelbrush.paint(); //paint the brush to the canvas (and update the brush, i.e. move it a little) pixelcanvas.transfer(); //transfer (add) the canvas to the FastLED FastLED.show(); } } //--------------------- //RAINBOW PAINT (aka nyan cat) //--------------------- // Animation void rainbowPaintRead() { // Serial.println(F(""in rainbow paint read"")); //the brush moves along the strip, leaving a colorful rainbow trail // for(loopcounter = 0; loopcounter= 2; k--) { heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; } // Step 3. Randomly ignite new 'sparks' of heat near the bottom if( random8() < SPARKING ) { int y = random8(7); heat[y] = qadd8( heat[y], random8(160,255) ); } // Step 4. Map from heat cells to LED colors for( int j = 0; j < NUM_LEDS; j++) { CRGB color = HeatColor( heat[j]); int pixelnumber; if( gReverseDirection ) { pixelnumber = (NUM_LEDS-1) - j; } else { pixelnumber = j; } leds[pixelnumber] = color; } FastLED.show(); // display this frame } void sparklerFireRead(uint8_t fireBrightness, bool reverse) { // Array of temperature readings at each simulation cell static byte heat[NUM_LEDS]; // Step 1. Cool down every cell a little for( int i = 0; i < NUM_LEDS; i++) { heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2)); } // Step 2. Heat from each cell drifts 'up' and diffuses a little for( int k= NUM_LEDS - 1; k >= 2; k--) { heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; } // Step 3. Randomly ignite new 'sparks' of heat near the bottom if( random8() < SPARKING ) { int y = random8(7); heat[y] = qadd8( heat[y], random8(100,255) ); } // Step 4. Map from heat cells to LED colors for( int j = 0; j < NUM_LEDS; j++) { // Scale the heat value from 0-255 down to 0-240 // for best results with color palettes. byte colorindex = scale8( heat[j], 240); CRGB color = ColorFromPalette( CRGBPalette16( CRGB::Black, CRGB::Red, CRGB::Orange, CRGB::BlueViolet), colorindex, fireBrightness); if (reverse) { color = ColorFromPalette( CRGBPalette16( CRGB::BlueViolet, CRGB::Orange, CRGB::Red, CRGB::Black), colorindex, fireBrightness); } int pixelnumber; if( gReverseDirection ) { pixelnumber = (NUM_LEDS-1) - j; } else { pixelnumber = j; } leds[pixelnumber] = color; } FastLED.show(); // display this frame } //SPARKLER: a brush seeding sparkles // Animation void sparklerRead() { // Serial.print(F(""in sparklerRead\\n"")); // float yaw = ypr[0] * 180/M_PI; // float pitch = ypr[1] * 180/M_PI; // float roll = ypr[2] * 180/M_PI; float yaw = ypr[0]; float pitch = ypr[1]; float roll = ypr[2]; //updateSpeed(roll * 5 + 600); if (initialized == false) { initialized = true; updateSpeed(5); pixelbrush.setSpeed(speed); // if(speed > 0) // pixelbrush.setSpeed(600); // else // pixelbrush.setSpeed(-600); pixelbrush.setFadeout(true); //sparkles fade in pixelbrush.setFadein(true); //and fade out immediately after reaching the set brightness } int saturation = 255 - abs(yaw) * 2.8; //set a new brush color in each loop brushcolor.h = random(255); //random color brushcolor.s = saturation; //random(130); //random but low saturation, giving white-ish sparkles int brightness = random(125); brushcolor.v = brightness; //random (peak) brighness pixelbrush.setColor(brushcolor); pixelbrush.setFadeSpeed(random(100) + 150); //set a new fadespeed with some randomness FastLED.clear(); pixelbrush.paint(); //paint the brush to the canvas (and update the brush, i.e. move it a little) pixelcanvas.transfer(); //transfer (add) the canvas to the FastLED if (DEBUG_OUTPUT) { printInfo(brightness); // Serial.print(""speed: ""); // Serial.print(speed); // if(speedController == ROLL) // Serial.println("" speedController: ROLL""); // else if(speedController == YAW) // Serial.println("" speedController: YAW""); // Serial.print(""\\nsaturation: ""); // Serial.print(saturation); // Serial.print(""\\n""); } FastLED.show(); } //SPARKLER: a brush seeding sparkles // Animation void sparkler() { Serial.println(F(""sparkler"")); for(loopcounter = 0; loopcounter 0) initialized = false; //choose new color & speed if brush reaches pixel 0 lastposition = pixelbrush.getPosition(); //save current position for next position check if (initialized == false) { initialized = true; //CHSV brushcolor; brushcolor.h = random(255); //random color brushcolor.s = 255; //full saturation brushcolor.v = 130; //medium brightness pixelbrush.setSpeed(random(150) + 150); //random movement speed pixelbrush.setFadeSpeed(random(10) + 20); //set random fading speed pixelbrush.setColor(brushcolor); //update the color of the brush pixelbrush.setFadeHueNear(true); //fade using the near path on the colorcircle //second brush paints on the same canvas brushcolor.h = random(255); pixelbrush2.setSpeed(random(150) + 150); pixelbrush2.setFadeSpeed(random(10) + 20); pixelbrush2.setColor(brushcolor); pixelbrush2.setFadeHueNear(true); //fade using the near path on the colorcircle //pixelbrush.setFadeHueFar(true); //fade using the far path on the colorcircle (if both are set, this path is chosen) pixelbrush2.setBounce(true); //bounce this brush at the end of the strip } FastLED.clear(); pixelbrush.paint(); //apply the paint of the first brush to the canvas (and update the brush) pixelbrush2.paint(); //apply the paint of the second brush to the canvas (and update the brush) pixelcanvas.transfer(); //transfer the canvas to the FastLED FastLED.show(); } break; //quit the while loop immediately (and delete the created brush) } } //------------------------------ //SPEEDTRAILS //------------------------------ //three brushes painting on one canvas, all following each other at the same speed, painting fading pixels // Animation void speedTrails() { Serial.println(F(""speed trails"")); while(true) //create a loop with two additional brushes (are deleted automatically once the loop finishes) { int brushspeed = 300; //moving speed was 900 but too fast for teensy //create additional brushes, painting on the same canvas as the globally defined brush FastLEDPainterBrush pixelbrush2 = FastLEDPainterBrush(&pixelcanvas); //crete brush, linked to the canvas to paint to FastLEDPainterBrush pixelbrush3 = FastLEDPainterBrush(&pixelcanvas); //crete brush, linked to the canvas to paint to if (pixelbrush2.isvalid() == false) Serial.println(F(""brush2 allocation problem"")); else Serial.println(F(""brush2 allocation ok"")); if (pixelbrush3.isvalid() == false) Serial.println(F(""brush3 allocation problem"")); else Serial.println(F(""brush3 allocation ok"")); for(loopcounter = 0; loopcounter= 250 && rollHistory.isFull()) { if (millis() - time >= 250) { time = millis(); // float avg = 0.0; // float sum = 0; // // the following ensures using the right type for the index variable // using index_t = decltype(rollHistory)::index_t; // for (index_t i = 0; i < rollHistory.size(); i++) { // // avg += buffer[i] / (float)buffer.size(); // // roll_rate += rollHistory[i] / (float)rollHistory.size(); // sum += rollHistory[i]; // } printInfo2(brushcolor.v); // roll_rate = sum / rollHistory.size(); // Serial.print(""Average is ""); roll_rate = pitch; Serial.print(""RATE is ""); Serial.print(abs(old_roll_rate - roll_rate)); Serial.print("" spinning: ""); Serial.println(spinning_animation); if (!spinning_animation && abs(old_roll_rate - roll_rate) > ROLL_THRESHOLD) { // should switch to standard animations spinning_animation = true; // rainbowPaintWithInput(); bouncyBallsWithInput(); } old_roll_rate = roll_rate; } // Serial.print(""Orientation [ypr]: ""); // Serial.print(yaw); // Serial.print("" ""); // Serial.print(pitch); // Serial.print("" ""); // Serial.println(roll); } } void readMpu() { // get current FIFO count fifoCount = mpu.getFIFOCount(); // wait for correct available data length, should be a VERY short wait //Serial.print(F(""in readMpu if first"")); while (fifoCount < packetSize && mpuIntStatus < 1) fifoCount = mpu.getFIFOCount(); //Serial.print(F(""after readMpu() while "")); // read a packet from FIFO mpu.getFIFOBytes(fifoBuffer, packetSize); // track FIFO count here in case there is > 1 packet available // (this lets us immediately read more without waiting for an interrupt) fifoCount -= packetSize; //HERE IS WHERE THE READS ACTUALLY HAPPEN #ifdef OUTPUT_READABLE_YAWPITCHROLL // display YAW PITCH AND ROLL angles in degrees mpu.dmpGetQuaternion(&qc, fifoBuffer); mpu.dmpGetGravity(&gravity, &qc); mpu.dmpGetYawPitchRoll(ypr, &qc, &gravity); float yaw = ypr[0] * 180/M_PI; float pitch = ypr[1] * 180/M_PI; float roll = ypr[2] * 180/M_PI; if(DEBUG_OUTPUT) { Serial.print(""\\typr\\t""); Serial.print(yaw); Serial.print(""\\t""); Serial.print(pitch); Serial.print(""\\t""); Serial.println(roll); } #endif // blink LED to indicate activity blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); } float readRollOld() { Serial.print(F(""in readRoll()"")); Serial.print(mpuIntStatus); mpuIntStatus = 1; if(0x02) Serial.print(F(""0x02"")); if (mpuIntStatus & 0x02 || true) { // wait for correct available data length, should be a VERY short wait Serial.print(F(""in readRoll if first"")); while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); Serial.print(F(""after readRoll() while"")); // read a packet from FIFO mpu.getFIFOBytes(fifoBuffer, packetSize); // track FIFO count here in case there is > 1 packet available // (this lets us immediately read more without waiting for an interrupt) fifoCount -= packetSize; //HERE IS WHERE THE READS ACTUALLY HAPPEN #ifdef OUTPUT_READABLE_YAWPITCHROLL // display YAW PITCH AND ROLL angles in degrees mpu.dmpGetQuaternion(&qc, fifoBuffer); mpu.dmpGetGravity(&gravity, &qc); mpu.dmpGetYawPitchRoll(ypr, &qc, &gravity); Serial.print(""ypr\\t""); float yaw = ypr[0] * 180/M_PI; Serial.print(yaw); Serial.print(""\\t""); float pitch = ypr[1] * 180/M_PI; Serial.print(pitch); Serial.print(""\\t""); float roll = ypr[2] * 180/M_PI; Serial.println(roll); #endif // blink LED to indicate activity blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); return roll; } } void drip() { boolean backward = true; //static signed int speed = 0; //for(loopcounter = 0; loopcounter < duration; loopcounter++) while(true) { static unsigned int hue = 0; //color hue to set to brush //CHSV brushcolor; //HSV color definition if (initialized == false) //initialize the brushes { initialized = true; pixelbrush.setFadeSpeed(90); pixelbrush.setFadein(false); //brightness will fade-in if set to true pixelbrush.setFadeout(true); pixelbrush.setBounce(false); } if(backward) { speed -= 1; brushcolor.h = 200; } else { speed += 1; brushcolor.h = 100; } if(speed > 300) { backward = true; } else if(speed < -300) backward = false; Serial.print(""speed""); Serial.print(speed); Serial.print(""\\n""); pixelbrush.setSpeed(speed); //brush moving speed //hue++; //brushcolor.h = hue; //divide by 3 to slow down color fading brushcolor.s = 255; //full saturation brushcolor.v = 255; //full brightness pixelbrush.setColor(brushcolor); //set new color to the bursh FastLED.clear(); pixelbrush.paint(); //paint the brush to the canvas (and update the brush, i.e. move it a little) pixelcanvas.transfer(); //transfer (add) the canvas to the FastLED FastLED.show(); } } ",16315,True,3449.2135674242145,median "/* Weather.ino Demonstrates: - Weather icons from open-iconic set. - Text scrolling. - Partial screen update This example requires display height >= 64. Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8g2lib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_PE12864_004_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_PE12864_004_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list #define SUN 0 #define SUN_CLOUD 1 #define CLOUD 2 #define RAIN 3 #define THUNDER 4 void drawWeatherSymbol(u8g2_uint_t x, u8g2_uint_t y, uint8_t symbol) { // fonts used: // u8g2_font_open_iconic_embedded_6x_t // u8g2_font_open_iconic_weather_6x_t // encoding values, see: https://github.com/olikraus/u8g2/wiki/fntgrpiconic switch(symbol) { case SUN: u8g2.setFont(u8g2_font_open_iconic_weather_6x_t); u8g2.drawGlyph(x, y, 69); break; case SUN_CLOUD: u8g2.setFont(u8g2_font_open_iconic_weather_6x_t); u8g2.drawGlyph(x, y, 65); break; case CLOUD: u8g2.setFont(u8g2_font_open_iconic_weather_6x_t); u8g2.drawGlyph(x, y, 64); break; case RAIN: u8g2.setFont(u8g2_font_open_iconic_weather_6x_t); u8g2.drawGlyph(x, y, 67); break; case THUNDER: u8g2.setFont(u8g2_font_open_iconic_embedded_6x_t); u8g2.drawGlyph(x, y, 67); break; } } void drawWeather(uint8_t symbol, int degree) { drawWeatherSymbol(0, 48, symbol); u8g2.setFont(u8g2_font_logisoso32_tf); u8g2.setCursor(48+3, 42); u8g2.print(degree); u8g2.print(""°C""); // requires enableUTF8Print() } /* Draw a string with specified pixel offset. The offset can be negative. Limitation: The monochrome font with 8 pixel per glyph */ void drawScrollString(int16_t offset, const char *s) { static char buf[36]; // should for screen with up to 256 pixel width size_t len; size_t char_offset = 0; u8g2_uint_t dx = 0; size_t visible = 0; u8g2.setDrawColor(0); // clear the scrolling area u8g2.drawBox(0, 49, u8g2.getDisplayWidth()-1, u8g2.getDisplayHeight()-1); u8g2.setDrawColor(1); // set the color for the text len = strlen(s); if ( offset < 0 ) { char_offset = (-offset)/8; dx = offset + char_offset*8; if ( char_offset >= u8g2.getDisplayWidth()/8 ) return; visible = u8g2.getDisplayWidth()/8-char_offset+1; strncpy(buf, s, visible); buf[visible] = '\\0'; u8g2.setFont(u8g2_font_8x13_mf); u8g2.drawStr(char_offset*8-dx, 62, buf); } else { char_offset = offset / 8; if ( char_offset >= len ) return; // nothing visible dx = offset - char_offset*8; visible = len - char_offset; if ( visible > u8g2.getDisplayWidth()/8+1 ) visible = u8g2.getDisplayWidth()/8+1; strncpy(buf, s+char_offset, visible); buf[visible] = '\\0'; u8g2.setFont(u8g2_font_8x13_mf); u8g2.drawStr(-dx, 62, buf); } } void draw(const char *s, uint8_t symbol, int degree) { int16_t offset = -(int16_t)u8g2.getDisplayWidth(); int16_t len = strlen(s); u8g2.clearBuffer(); // clear the internal memory drawWeather(symbol, degree); // draw the icon and degree only once for(;;) // then do the scrolling { drawScrollString(offset, s); // no clearBuffer required, screen will be partially cleared here u8g2.sendBuffer(); // transfer internal memory to the display delay(20); offset+=2; if ( offset > len*8+1 ) break; } } void setup(void) { /* U8g2 Project: SSD1306 Test Board */ pinMode(10, OUTPUT); pinMode(9, OUTPUT); digitalWrite(10, 0); digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); /* U8g2 Project: LC7981 Test Board, connect RW to GND */ //pinMode(17, OUTPUT); //digitalWrite(17, 0); /* U8g2 Project: Pax Instruments Shield: Enable Backlight */ //pinMode(6, OUTPUT); //digitalWrite(6, 0); u8g2.begin(); u8g2.enableUTF8Print(); } void loop(void) { draw(""What a beautiful day!"", SUN, 27); draw(""The sun's come out!"", SUN_CLOUD, 19); draw(""It's raining cats and dogs."", RAIN, 8); draw(""That sounds like thunder."", THUNDER, 12); draw(""It's stopped raining"", CLOUD, 15); } ",16235,True,4577.321355122744,median "package { import com.adobe.serialization.json.JSONDecoder; import flash.display.Sprite; import ruby.internals.RbISeq; import ruby.internals.RubyCore; import ruby.internals.RubyFrame; public class RubyVMMain extends Sprite { public function RubyVMMain() { super(); var rc:RubyCore = new RubyCore(); // Must do ruby_init to prep for creating iseq. rc.run(get_bytecode(), this); } protected function get_bytecode():String { var s:String = //""[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":2,\\""stack_max\\"":5},\\""\\"",\\""\\"",\\""top\\"",[\\""v\\""],0,[],[1,[\\""trace\\"",1],[\\""putstring\\"",\\""hi\\""],[\\""setlocal\\"",2],2,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""pt\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":3,\\""local_size\\"":4,\\""stack_max\\"":2},\\""pt\\"",\\""\\"",\\""method\\"",[\\""a\\"",\\""b\\"",\\""c\\""],3,[],[4,[\\""trace\\"",8],3,[\\""trace\\"",1],[\\""getlocal\\"",4],[\\""getlocal\\"",3],[\\""opt_plus\\""],[\\""getlocal\\"",2],[\\""opt_plus\\""],4,[\\""trace\\"",16],3,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],[\\""pop\\""],5,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""mimic\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":1,\\""local_size\\"":2,\\""stack_max\\"":1},\\""mimic\\"",\\""\\"",\\""method\\"",[\\""a\\""],1,[],[7,[\\""trace\\"",8],6,[\\""trace\\"",1],[\\""getlocal\\"",2],7,[\\""trace\\"",16],6,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],[\\""pop\\""],8,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""wait\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""wait\\"",\\""\\"",\\""method\\"",[],0,[],[10,[\\""trace\\"",8],9,[\\""trace\\"",1],[\\""putstring\\"",\\""done waiting\\""],10,[\\""trace\\"",16],9,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],[\\""pop\\""],11,[\\""trace\\"",1],[\\""putnil\\""],[\\""putnil\\""],[\\""putstring\\"",\\""wait 5\\""],[\\""send\\"",\\""mimic\\"",1,null,8,null],[\\""send\\"",\\""puts\\"",1,null,8,null],[\\""pop\\""],12,[\\""trace\\"",1],[\\""putnil\\""],[\\""putnil\\""],[\\""send\\"",\\""wait\\"",0,null,8,null],[\\""send\\"",\\""puts\\"",1,null,8,null],[\\""pop\\""],13,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""col\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""col\\"",\\""\\"",\\""method\\"",[],0,[],[15,[\\""trace\\"",8],14,[\\""trace\\"",1],[\\""putobject\\"",65280],15,[\\""trace\\"",16],14,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],[\\""pop\\""],16,[\\""trace\\"",1],\\""label_112\\"",[\\""getinlinecache\\"",null,\\""label_119\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_112\\""],\\""label_119\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""send\\"",\\""lineStyle\\"",3,null,0,null],[\\""pop\\""],17,[\\""trace\\"",1],\\""label_140\\"",[\\""getinlinecache\\"",null,\\""label_147\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_140\\""],\\""label_147\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putnil\\""],[\\""send\\"",\\""col\\"",0,null,24,null],[\\""send\\"",\\""beginFill\\"",1,null,0,null],[\\""pop\\""],18,[\\""trace\\"",1],\\""label_169\\"",[\\""getinlinecache\\"",null,\\""label_176\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_169\\""],\\""label_176\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",5],[\\""putobject\\"",5],[\\""putobject\\"",105],[\\""putobject\\"",105],[\\""send\\"",\\""drawRect\\"",4,null,0,null],[\\""leave\\""]]]""; //some functions //""[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":2,\\""stack_max\\"":5},\\""\\"",\\""\\"",\\""top\\"",[\\""v\\""],0,[],[1,[\\""trace\\"",1],[\\""putstring\\"",\\""hi\\""],[\\""setlocal\\"",2],2,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""pt\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":3,\\""local_size\\"":4,\\""stack_max\\"":2},\\""pt\\"",\\""\\"",\\""method\\"",[\\""a\\"",\\""b\\"",\\""c\\""],3,[],[4,[\\""trace\\"",8],3,[\\""trace\\"",1],[\\""getlocal\\"",4],[\\""getlocal\\"",3],[\\""opt_plus\\""],[\\""getlocal\\"",2],[\\""opt_plus\\""],4,[\\""trace\\"",16],3,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],[\\""pop\\""],5,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""mimic\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":1,\\""local_size\\"":2,\\""stack_max\\"":1},\\""mimic\\"",\\""\\"",\\""method\\"",[\\""a\\""],1,[],[7,[\\""trace\\"",8],6,[\\""trace\\"",1],[\\""getlocal\\"",2],7,[\\""trace\\"",16],6,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],[\\""pop\\""],8,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""wait\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""wait\\"",\\""\\"",\\""method\\"",[],0,[],[10,[\\""trace\\"",8],9,[\\""trace\\"",1],[\\""putstring\\"",\\""done waiting\\""],10,[\\""trace\\"",16],9,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],[\\""pop\\""],11,[\\""trace\\"",1],[\\""putnil\\""],[\\""putnil\\""],[\\""putstring\\"",\\""wait 5\\""],[\\""send\\"",\\""mimic\\"",1,null,8,null],[\\""send\\"",\\""puts\\"",1,null,8,null],[\\""pop\\""],12,[\\""trace\\"",1],[\\""putnil\\""],[\\""putnil\\""],[\\""send\\"",\\""wait\\"",0,null,8,null],[\\""send\\"",\\""puts\\"",1,null,8,null],[\\""pop\\""],13,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""col\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""col\\"",\\""\\"",\\""method\\"",[],0,[],[15,[\\""trace\\"",8],14,[\\""trace\\"",1],[\\""putobject\\"",255],15,[\\""trace\\"",16],14,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],[\\""pop\\""],16,[\\""trace\\"",1],\\""label_112\\"",[\\""getinlinecache\\"",null,\\""label_119\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_112\\""],\\""label_119\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""send\\"",\\""lineStyle\\"",3,null,0,null],[\\""pop\\""],17,[\\""trace\\"",1],\\""label_140\\"",[\\""getinlinecache\\"",null,\\""label_147\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_140\\""],\\""label_147\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putnil\\""],[\\""send\\"",\\""col\\"",0,null,24,null],[\\""send\\"",\\""beginFill\\"",1,null,0,null],[\\""pop\\""],18,[\\""trace\\"",1],\\""label_169\\"",[\\""getinlinecache\\"",null,\\""label_176\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_169\\""],\\""label_176\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",5],[\\""putobject\\"",5],[\\""putobject\\"",105],[\\""putobject\\"",105],[\\""send\\"",\\""drawRect\\"",4,null,0,null],[\\""leave\\""]]]""; // create class //""[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":2,\\""stack_max\\"":2},\\""\\"",\\""\\"",\\""top\\"",[\\""a\\""],0,[],[1,[\\""trace\\"",1],[\\""putspecialobject\\"",2],[\\""putnil\\""],[\\""defineclass\\"",\\""A\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":4},\\""\\"",\\""\\"",\\""class\\"",[],0,[],[10,[\\""trace\\"",2],2,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""col\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""col\\"",\\""\\"",\\""method\\"",[],0,[],[4,[\\""trace\\"",8],3,[\\""trace\\"",1],[\\""putobject\\"",3368499],4,[\\""trace\\"",16],3,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],[\\""pop\\""],5,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""a\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":5},\\""a\\"",\\""\\"",\\""method\\"",[],0,[],[9,[\\""trace\\"",8],6,[\\""trace\\"",1],\\""label_4\\"",[\\""getinlinecache\\"",null,\\""label_11\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_4\\""],\\""label_11\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""send\\"",\\""lineStyle\\"",3,null,0,null],[\\""pop\\""],7,[\\""trace\\"",1],\\""label_32\\"",[\\""getinlinecache\\"",null,\\""label_39\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_32\\""],\\""label_39\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putnil\\""],[\\""send\\"",\\""col\\"",0,null,24,null],[\\""send\\"",\\""beginFill\\"",1,null,0,null],[\\""pop\\""],8,[\\""trace\\"",1],\\""label_61\\"",[\\""getinlinecache\\"",null,\\""label_68\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_61\\""],\\""label_68\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",5],[\\""putobject\\"",5],[\\""putobject\\"",105],[\\""putobject\\"",105],[\\""send\\"",\\""drawRect\\"",4,null,0,null],9,[\\""trace\\"",16],8,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],10,[\\""trace\\"",4],5,[\\""leave\\""]]],0],[\\""pop\\""],11,[\\""trace\\"",1],\\""label_12\\"",[\\""getinlinecache\\"",null,\\""label_19\\""],[\\""getconstant\\"",\\""A\\""],[\\""setinlinecache\\"",\\""label_12\\""],\\""label_19\\"",[\\""send\\"",\\""new\\"",0,null,0,null],[\\""setlocal\\"",2],12,[\\""trace\\"",1],[\\""getlocal\\"",2],[\\""send\\"",\\""a\\"",0,null,0,null],[\\""leave\\""]]]""; // class + module //""[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":2,\\""stack_max\\"":2},\\""\\"",\\""\\"",\\""top\\"",[\\""a\\""],0,[],[1,[\\""trace\\"",1],[\\""putspecialobject\\"",2],[\\""putnil\\""],[\\""defineclass\\"",\\""B\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":4},\\""\\"",\\""\\"",\\""class\\"",[],0,[],[5,[\\""trace\\"",2],2,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""col\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""col\\"",\\""\\"",\\""method\\"",[],0,[],[4,[\\""trace\\"",8],3,[\\""trace\\"",1],[\\""putobject\\"",6697762],4,[\\""trace\\"",16],3,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],5,[\\""trace\\"",4],2,[\\""leave\\""]]],2],[\\""pop\\""],6,[\\""trace\\"",1],[\\""putspecialobject\\"",2],[\\""putnil\\""],[\\""defineclass\\"",\\""A\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":4},\\""\\"",\\""\\"",\\""class\\"",[],0,[],[13,[\\""trace\\"",2],7,[\\""trace\\"",1],[\\""putnil\\""],\\""label_5\\"",[\\""getinlinecache\\"",null,\\""label_12\\""],[\\""getconstant\\"",\\""B\\""],[\\""setinlinecache\\"",\\""label_5\\""],\\""label_12\\"",[\\""send\\"",\\""include\\"",1,null,8,null],[\\""pop\\""],8,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""a\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":5},\\""a\\"",\\""\\"",\\""method\\"",[],0,[],[12,[\\""trace\\"",8],9,[\\""trace\\"",1],\\""label_4\\"",[\\""getinlinecache\\"",null,\\""label_11\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_4\\""],\\""label_11\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""send\\"",\\""lineStyle\\"",3,null,0,null],[\\""pop\\""],10,[\\""trace\\"",1],\\""label_32\\"",[\\""getinlinecache\\"",null,\\""label_39\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_32\\""],\\""label_39\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putnil\\""],[\\""send\\"",\\""col\\"",0,null,24,null],[\\""send\\"",\\""beginFill\\"",1,null,0,null],[\\""pop\\""],11,[\\""trace\\"",1],\\""label_61\\"",[\\""getinlinecache\\"",null,\\""label_68\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_61\\""],\\""label_68\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",5],[\\""putobject\\"",5],[\\""putobject\\"",105],[\\""putobject\\"",105],[\\""send\\"",\\""drawRect\\"",4,null,0,null],12,[\\""trace\\"",16],11,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],13,[\\""trace\\"",4],8,[\\""leave\\""]]],0],[\\""pop\\""],14,[\\""trace\\"",1],\\""label_22\\"",[\\""getinlinecache\\"",null,\\""label_29\\""],[\\""getconstant\\"",\\""A\\""],[\\""setinlinecache\\"",\\""label_22\\""],\\""label_29\\"",[\\""send\\"",\\""new\\"",0,null,0,null],[\\""setlocal\\"",2],15,[\\""trace\\"",1],[\\""getlocal\\"",2],[\\""send\\"",\\""a\\"",0,null,0,null],[\\""leave\\""]]]""; // obj.extend module //""[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":2,\\""stack_max\\"":2},\\""\\"",\\""\\"",\\""top\\"",[\\""a\\""],0,[],[1,[\\""trace\\"",1],[\\""putspecialobject\\"",2],[\\""putnil\\""],[\\""defineclass\\"",\\""B\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":4},\\""\\"",\\""\\"",\\""class\\"",[],0,[],[5,[\\""trace\\"",2],2,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""col\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""col\\"",\\""\\"",\\""method\\"",[],0,[],[4,[\\""trace\\"",8],3,[\\""trace\\"",1],[\\""putobject\\"",6697898],4,[\\""trace\\"",16],3,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],5,[\\""trace\\"",4],2,[\\""leave\\""]]],2],[\\""pop\\""],6,[\\""trace\\"",1],[\\""putspecialobject\\"",2],[\\""putnil\\""],[\\""defineclass\\"",\\""A\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":4},\\""\\"",\\""\\"",\\""class\\"",[],0,[],[12,[\\""trace\\"",2],7,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""a\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":5},\\""a\\"",\\""\\"",\\""method\\"",[],0,[],[11,[\\""trace\\"",8],8,[\\""trace\\"",1],\\""label_4\\"",[\\""getinlinecache\\"",null,\\""label_11\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_4\\""],\\""label_11\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""send\\"",\\""lineStyle\\"",3,null,0,null],[\\""pop\\""],9,[\\""trace\\"",1],\\""label_32\\"",[\\""getinlinecache\\"",null,\\""label_39\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_32\\""],\\""label_39\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putnil\\""],[\\""send\\"",\\""col\\"",0,null,24,null],[\\""send\\"",\\""beginFill\\"",1,null,0,null],[\\""pop\\""],10,[\\""trace\\"",1],\\""label_61\\"",[\\""getinlinecache\\"",null,\\""label_68\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_61\\""],\\""label_68\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",5],[\\""putobject\\"",5],[\\""putobject\\"",105],[\\""putobject\\"",105],[\\""send\\"",\\""drawRect\\"",4,null,0,null],11,[\\""trace\\"",16],10,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],12,[\\""trace\\"",4],7,[\\""leave\\""]]],0],[\\""pop\\""],13,[\\""trace\\"",1],\\""label_22\\"",[\\""getinlinecache\\"",null,\\""label_29\\""],[\\""getconstant\\"",\\""A\\""],[\\""setinlinecache\\"",\\""label_22\\""],\\""label_29\\"",[\\""send\\"",\\""new\\"",0,null,0,null],[\\""setlocal\\"",2],14,[\\""trace\\"",1],[\\""getlocal\\"",2],\\""label_41\\"",[\\""getinlinecache\\"",null,\\""label_48\\""],[\\""getconstant\\"",\\""B\\""],[\\""setinlinecache\\"",\\""label_41\\""],\\""label_48\\"",[\\""send\\"",\\""extend\\"",1,null,0,null],[\\""pop\\""],15,[\\""trace\\"",1],[\\""getlocal\\"",2],[\\""send\\"",\\""a\\"",0,null,0,null],[\\""leave\\""]]]""; // block and yield //""[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":2,\\""stack_max\\"":2},\\""\\"",\\""\\"",\\""top\\"",[\\""a\\""],0,[[\\""break\\"",null,\\""label_57\\"",\\""label_65\\"",\\""label_65\\"",0]],[1,[\\""trace\\"",1],[\\""putspecialobject\\"",2],[\\""putnil\\""],[\\""defineclass\\"",\\""B\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":4},\\""\\"",\\""\\"",\\""class\\"",[],0,[],[5,[\\""trace\\"",2],2,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""col\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""col\\"",\\""\\"",\\""method\\"",[],0,[],[4,[\\""trace\\"",8],3,[\\""trace\\"",1],[\\""putobject\\"",6728243],4,[\\""trace\\"",16],3,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],5,[\\""trace\\"",4],2,[\\""leave\\""]]],2],[\\""pop\\""],6,[\\""trace\\"",1],[\\""putspecialobject\\"",2],[\\""putnil\\""],[\\""defineclass\\"",\\""A\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":4},\\""\\"",\\""\\"",\\""class\\"",[],0,[],[10,[\\""trace\\"",2],7,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""a\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""a\\"",\\""\\"",\\""method\\"",[],0,[],[9,[\\""trace\\"",8],8,[\\""trace\\"",1],[\\""invokeblock\\"",0,0],9,[\\""trace\\"",16],8,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],10,[\\""trace\\"",4],7,[\\""leave\\""]]],0],[\\""pop\\""],11,[\\""trace\\"",1],\\""label_22\\"",[\\""getinlinecache\\"",null,\\""label_29\\""],[\\""getconstant\\"",\\""A\\""],[\\""setinlinecache\\"",\\""label_22\\""],\\""label_29\\"",[\\""send\\"",\\""new\\"",0,null,0,null],[\\""setlocal\\"",2],12,[\\""trace\\"",1],[\\""getlocal\\"",2],\\""label_41\\"",[\\""getinlinecache\\"",null,\\""label_48\\""],[\\""getconstant\\"",\\""B\\""],[\\""setinlinecache\\"",\\""label_41\\""],\\""label_48\\"",[\\""send\\"",\\""extend\\"",1,null,0,null],[\\""pop\\""],13,[\\""trace\\"",1],\\""label_57\\"",[\\""getlocal\\"",2],[\\""send\\"",\\""a\\"",0,[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":5},\\""block in \\"",\\""\\"",\\""block\\"",[],0,[[\\""redo\\"",null,\\""label_0\\"",\\""label_81\\"",\\""label_0\\"",0],[\\""next\\"",null,\\""label_0\\"",\\""label_81\\"",\\""label_81\\"",0]],[\\""label_0\\"",14,[\\""trace\\"",1],\\""label_2\\"",[\\""getinlinecache\\"",null,\\""label_9\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_2\\""],\\""label_9\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""send\\"",\\""lineStyle\\"",3,null,0,null],[\\""pop\\""],15,[\\""trace\\"",1],\\""label_30\\"",[\\""getinlinecache\\"",null,\\""label_37\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_30\\""],\\""label_37\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",3386094],[\\""send\\"",\\""beginFill\\"",1,null,0,null],[\\""pop\\""],16,[\\""trace\\"",1],\\""label_54\\"",[\\""getinlinecache\\"",null,\\""label_61\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_54\\""],\\""label_61\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",5],[\\""putobject\\"",5],[\\""putobject\\"",105],[\\""putobject\\"",105],[\\""send\\"",\\""drawRect\\"",4,null,0,null],\\""label_81\\"",[\\""leave\\""]]],0,null],\\""label_65\\"",[\\""leave\\""]]]""; // create new Sprite //""[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":2,\\""stack_max\\"":2},\\""\\"",\\""\\"",\\""top\\"",[\\""a\\""],0,[[\\""break\\"",null,\\""label_57\\"",\\""label_65\\"",\\""label_65\\"",0]],[1,[\\""trace\\"",1],[\\""putspecialobject\\"",2],[\\""putnil\\""],[\\""defineclass\\"",\\""B\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":4},\\""\\"",\\""\\"",\\""class\\"",[],0,[],[5,[\\""trace\\"",2],2,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""col\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""col\\"",\\""\\"",\\""method\\"",[],0,[],[4,[\\""trace\\"",8],3,[\\""trace\\"",1],[\\""putobject\\"",6728243],4,[\\""trace\\"",16],3,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],5,[\\""trace\\"",4],2,[\\""leave\\""]]],2],[\\""pop\\""],6,[\\""trace\\"",1],[\\""putspecialobject\\"",2],[\\""putnil\\""],[\\""defineclass\\"",\\""A\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":4},\\""\\"",\\""\\"",\\""class\\"",[],0,[],[10,[\\""trace\\"",2],7,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""a\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""a\\"",\\""\\"",\\""method\\"",[],0,[],[9,[\\""trace\\"",8],8,[\\""trace\\"",1],[\\""invokeblock\\"",0,0],9,[\\""trace\\"",16],8,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],10,[\\""trace\\"",4],7,[\\""leave\\""]]],0],[\\""pop\\""],11,[\\""trace\\"",1],\\""label_22\\"",[\\""getinlinecache\\"",null,\\""label_29\\""],[\\""getconstant\\"",\\""A\\""],[\\""setinlinecache\\"",\\""label_22\\""],\\""label_29\\"",[\\""send\\"",\\""new\\"",0,null,0,null],[\\""setlocal\\"",2],12,[\\""trace\\"",1],[\\""getlocal\\"",2],\\""label_41\\"",[\\""getinlinecache\\"",null,\\""label_48\\""],[\\""getconstant\\"",\\""B\\""],[\\""setinlinecache\\"",\\""label_41\\""],\\""label_48\\"",[\\""send\\"",\\""extend\\"",1,null,0,null],[\\""pop\\""],13,[\\""trace\\"",1],\\""label_57\\"",[\\""getlocal\\"",2],[\\""send\\"",\\""a\\"",0,[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":2,\\""stack_max\\"":5},\\""block in \\"",\\""\\"",\\""block\\"",[\\""s\\""],0,[[\\""redo\\"",null,\\""label_0\\"",\\""label_110\\"",\\""label_0\\"",0],[\\""next\\"",null,\\""label_0\\"",\\""label_110\\"",\\""label_110\\"",0]],[\\""label_0\\"",14,[\\""trace\\"",1],\\""label_2\\"",[\\""getinlinecache\\"",null,\\""label_13\\""],[\\""getconstant\\"",\\""Flash\\""],[\\""getconstant\\"",\\""Display\\""],[\\""getconstant\\"",\\""Sprite\\""],[\\""setinlinecache\\"",\\""label_2\\""],\\""label_13\\"",[\\""send\\"",\\""new\\"",0,null,0,null],[\\""setdynamic\\"",2,0],15,[\\""trace\\"",1],\\""label_24\\"",[\\""getinlinecache\\"",null,\\""label_31\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_24\\""],\\""label_31\\"",[\\""getdynamic\\"",2,0],[\\""send\\"",\\""addChild\\"",1,null,0,null],[\\""pop\\""],16,[\\""trace\\"",1],[\\""getdynamic\\"",2,0],[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""send\\"",\\""lineStyle\\"",3,null,0,null],[\\""pop\\""],17,[\\""trace\\"",1],[\\""getdynamic\\"",2,0],[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",3386094],[\\""send\\"",\\""beginFill\\"",1,null,0,null],[\\""pop\\""],18,[\\""trace\\"",1],[\\""getdynamic\\"",2,0],[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",5],[\\""putobject\\"",5],[\\""putobject\\"",105],[\\""putobject\\"",105],[\\""send\\"",\\""drawRect\\"",4,null,0,null],\\""label_110\\"",[\\""leave\\""]]],0,null],\\""label_65\\"",[\\""leave\\""]]]""; // access variable from closure scope //""[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":3,\\""stack_max\\"":2},\\""\\"",\\""\\"",\\""top\\"",[\\""a\\"",\\""s\\""],0,[[\\""break\\"",null,\\""label_78\\"",\\""label_86\\"",\\""label_86\\"",0]],[1,[\\""trace\\"",1],[\\""putspecialobject\\"",2],[\\""putnil\\""],[\\""defineclass\\"",\\""B\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":4},\\""\\"",\\""\\"",\\""class\\"",[],0,[],[5,[\\""trace\\"",2],2,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""col\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""col\\"",\\""\\"",\\""method\\"",[],0,[],[4,[\\""trace\\"",8],3,[\\""trace\\"",1],[\\""putobject\\"",6728243],4,[\\""trace\\"",16],3,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],5,[\\""trace\\"",4],2,[\\""leave\\""]]],2],[\\""pop\\""],6,[\\""trace\\"",1],[\\""putspecialobject\\"",2],[\\""putnil\\""],[\\""defineclass\\"",\\""A\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":4},\\""\\"",\\""\\"",\\""class\\"",[],0,[],[10,[\\""trace\\"",2],7,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""a\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""a\\"",\\""\\"",\\""method\\"",[],0,[],[9,[\\""trace\\"",8],8,[\\""trace\\"",1],[\\""invokeblock\\"",0,0],9,[\\""trace\\"",16],8,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],10,[\\""trace\\"",4],7,[\\""leave\\""]]],0],[\\""pop\\""],11,[\\""trace\\"",1],\\""label_22\\"",[\\""getinlinecache\\"",null,\\""label_29\\""],[\\""getconstant\\"",\\""A\\""],[\\""setinlinecache\\"",\\""label_22\\""],\\""label_29\\"",[\\""send\\"",\\""new\\"",0,null,0,null],[\\""setlocal\\"",3],12,[\\""trace\\"",1],[\\""getlocal\\"",3],\\""label_41\\"",[\\""getinlinecache\\"",null,\\""label_48\\""],[\\""getconstant\\"",\\""B\\""],[\\""setinlinecache\\"",\\""label_41\\""],\\""label_48\\"",[\\""send\\"",\\""extend\\"",1,null,0,null],[\\""pop\\""],13,[\\""trace\\"",1],\\""label_57\\"",[\\""getinlinecache\\"",null,\\""label_68\\""],[\\""getconstant\\"",\\""Flash\\""],[\\""getconstant\\"",\\""Display\\""],[\\""getconstant\\"",\\""Sprite\\""],[\\""setinlinecache\\"",\\""label_57\\""],\\""label_68\\"",[\\""send\\"",\\""new\\"",0,null,0,null],[\\""setlocal\\"",2],14,[\\""trace\\"",1],\\""label_78\\"",[\\""getlocal\\"",3],[\\""send\\"",\\""a\\"",0,[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":5},\\""block in \\"",\\""\\"",\\""block\\"",[],0,[[\\""redo\\"",null,\\""label_0\\"",\\""label_88\\"",\\""label_0\\"",0],[\\""next\\"",null,\\""label_0\\"",\\""label_88\\"",\\""label_88\\"",0]],[\\""label_0\\"",15,[\\""trace\\"",1],\\""label_2\\"",[\\""getinlinecache\\"",null,\\""label_9\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_2\\""],\\""label_9\\"",[\\""getdynamic\\"",2,1],[\\""send\\"",\\""addChild\\"",1,null,0,null],[\\""pop\\""],16,[\\""trace\\"",1],[\\""getdynamic\\"",2,1],[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""send\\"",\\""lineStyle\\"",3,null,0,null],[\\""pop\\""],17,[\\""trace\\"",1],[\\""getdynamic\\"",2,1],[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",3386094],[\\""send\\"",\\""beginFill\\"",1,null,0,null],[\\""pop\\""],18,[\\""trace\\"",1],[\\""getdynamic\\"",2,1],[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",5],[\\""putobject\\"",5],[\\""putobject\\"",105],[\\""putobject\\"",105],[\\""send\\"",\\""drawRect\\"",4,null,0,null],\\""label_88\\"",[\\""leave\\""]]],0,null],\\""label_86\\"",[\\""leave\\""]]]""; // yield a value //""[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":2,\\""stack_max\\"":2},\\""\\"",\\""\\"",\\""top\\"",[\\""a\\""],0,[[\\""break\\"",null,\\""label_57\\"",\\""label_65\\"",\\""label_65\\"",0]],[1,[\\""trace\\"",1],[\\""putspecialobject\\"",2],[\\""putnil\\""],[\\""defineclass\\"",\\""B\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":4},\\""\\"",\\""\\"",\\""class\\"",[],0,[],[5,[\\""trace\\"",2],2,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""col\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":1},\\""col\\"",\\""\\"",\\""method\\"",[],0,[],[4,[\\""trace\\"",8],3,[\\""trace\\"",1],[\\""putobject\\"",6728243],4,[\\""trace\\"",16],3,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],5,[\\""trace\\"",4],2,[\\""leave\\""]]],2],[\\""pop\\""],6,[\\""trace\\"",1],[\\""putspecialobject\\"",2],[\\""putnil\\""],[\\""defineclass\\"",\\""A\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":1,\\""stack_max\\"":4},\\""\\"",\\""\\"",\\""class\\"",[],0,[],[11,[\\""trace\\"",2],7,[\\""trace\\"",1],[\\""putspecialobject\\"",1],[\\""putspecialobject\\"",2],[\\""putobject\\"",\\""a\\""],[\\""putiseq\\"",[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":2,\\""stack_max\\"":1},\\""a\\"",\\""\\"",\\""method\\"",[\\""sp\\""],0,[],[10,[\\""trace\\"",8],8,[\\""trace\\"",1],\\""label_4\\"",[\\""getinlinecache\\"",null,\\""label_15\\""],[\\""getconstant\\"",\\""Flash\\""],[\\""getconstant\\"",\\""Display\\""],[\\""getconstant\\"",\\""Sprite\\""],[\\""setinlinecache\\"",\\""label_4\\""],\\""label_15\\"",[\\""send\\"",\\""new\\"",0,null,0,null],[\\""setlocal\\"",2],9,[\\""trace\\"",1],[\\""getlocal\\"",2],[\\""invokeblock\\"",1,0],10,[\\""trace\\"",16],9,[\\""leave\\""]]]],[\\""send\\"",\\""core#define_method\\"",3,null,0,null],11,[\\""trace\\"",4],7,[\\""leave\\""]]],0],[\\""pop\\""],12,[\\""trace\\"",1],\\""label_22\\"",[\\""getinlinecache\\"",null,\\""label_29\\""],[\\""getconstant\\"",\\""A\\""],[\\""setinlinecache\\"",\\""label_22\\""],\\""label_29\\"",[\\""send\\"",\\""new\\"",0,null,0,null],[\\""setlocal\\"",2],13,[\\""trace\\"",1],[\\""getlocal\\"",2],\\""label_41\\"",[\\""getinlinecache\\"",null,\\""label_48\\""],[\\""getconstant\\"",\\""B\\""],[\\""setinlinecache\\"",\\""label_41\\""],\\""label_48\\"",[\\""send\\"",\\""extend\\"",1,null,0,null],[\\""pop\\""],14,[\\""trace\\"",1],\\""label_57\\"",[\\""getlocal\\"",2],[\\""send\\"",\\""a\\"",0,[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":1,\\""local_size\\"":2,\\""stack_max\\"":5},\\""block in \\"",\\""\\"",\\""block\\"",[\\""s\\""],[1,[],0,0,-1,-1,3],[[\\""redo\\"",null,\\""label_0\\"",\\""label_88\\"",\\""label_0\\"",0],[\\""next\\"",null,\\""label_0\\"",\\""label_88\\"",\\""label_88\\"",0]],[\\""label_0\\"",15,[\\""trace\\"",1],\\""label_2\\"",[\\""getinlinecache\\"",null,\\""label_9\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_2\\""],\\""label_9\\"",[\\""getdynamic\\"",2,0],[\\""send\\"",\\""addChild\\"",1,null,0,null],[\\""pop\\""],16,[\\""trace\\"",1],[\\""getdynamic\\"",2,0],[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""send\\"",\\""lineStyle\\"",3,null,0,null],[\\""pop\\""],17,[\\""trace\\"",1],[\\""getdynamic\\"",2,0],[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",3386094],[\\""send\\"",\\""beginFill\\"",1,null,0,null],[\\""pop\\""],18,[\\""trace\\"",1],[\\""getdynamic\\"",2,0],[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",5],[\\""putobject\\"",5],[\\""putobject\\"",105],[\\""putobject\\"",105],[\\""send\\"",\\""drawRect\\"",4,null,0,null],\\""label_88\\"",[\\""leave\\""]]],0,null],\\""label_65\\"",[\\""leave\\""]]]""; // create an array //""[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":2,\\""stack_max\\"":5},\\""\\"",\\""\\"",\\""top\\"",[\\""a\\""],0,[],[1,[\\""trace\\"",1],[\\""duparray\\"",[1,1,1]],[\\""setlocal\\"",2],2,[\\""trace\\"",1],\\""label_8\\"",[\\""getinlinecache\\"",null,\\""label_15\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_8\\""],\\""label_15\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""putobject\\"",1],[\\""send\\"",\\""lineStyle\\"",3,null,0,null],[\\""pop\\""],3,[\\""trace\\"",1],\\""label_36\\"",[\\""getinlinecache\\"",null,\\""label_43\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_36\\""],\\""label_43\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",3386094],[\\""send\\"",\\""beginFill\\"",1,null,0,null],[\\""pop\\""],4,[\\""trace\\"",1],\\""label_60\\"",[\\""getinlinecache\\"",null,\\""label_67\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_60\\""],\\""label_67\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",5],[\\""putobject\\"",5],[\\""putobject\\"",105],[\\""putobject\\"",105],[\\""send\\"",\\""drawRect\\"",4,null,0,null],[\\""leave\\""]]]""; // array aref ""[\\""YARVInstructionSequence\\\\/SimpleDataFormat\\"",1,1,1,{\\""arg_size\\"":0,\\""local_size\\"":2,\\""stack_max\\"":5},\\""\\"",\\""\\"",\\""top\\"",[\\""a\\""],0,[],[1,[\\""trace\\"",1],[\\""duparray\\"",[1,1,1]],[\\""setlocal\\"",2],2,[\\""trace\\"",1],\\""label_8\\"",[\\""getinlinecache\\"",null,\\""label_15\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_8\\""],\\""label_15\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""getlocal\\"",2],[\\""putobject\\"",0],[\\""opt_aref\\""],[\\""getlocal\\"",2],[\\""putobject\\"",1],[\\""opt_aref\\""],[\\""getlocal\\"",2],[\\""putobject\\"",2],[\\""opt_aref\\""],[\\""send\\"",\\""lineStyle\\"",3,null,0,null],[\\""pop\\""],3,[\\""trace\\"",1],\\""label_45\\"",[\\""getinlinecache\\"",null,\\""label_52\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_45\\""],\\""label_52\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",3386094],[\\""send\\"",\\""beginFill\\"",1,null,0,null],[\\""pop\\""],4,[\\""trace\\"",1],\\""label_69\\"",[\\""getinlinecache\\"",null,\\""label_76\\""],[\\""getconstant\\"",\\""Document\\""],[\\""setinlinecache\\"",\\""label_69\\""],\\""label_76\\"",[\\""send\\"",\\""graphics\\"",0,null,0,null],[\\""putobject\\"",5],[\\""putobject\\"",5],[\\""putobject\\"",105],[\\""putobject\\"",105],[\\""send\\"",\\""drawRect\\"",4,null,0,null],[\\""leave\\""]]]""; return s; } protected function get_iseq(rc:RubyCore):Array { var s:String = get_bytecode(); var decoder:JSONDecoder = new JSONDecoder( s, rc ) return decoder.getValue(); //return JSON.decode(s); } protected function ruby_iseq2(rc:RubyCore):Array { return [ ""YARVInstructionSequence/SimpleDataFormat"", 1, 1, 1, {arg_size:0, local_size:2, stack_max:5}, """", """", ""top"", [""v""], 0, [], [ [""putstring"", ""hi""], [""setlocal"", 2], [""putspecialobject"", 1], [""putspecialobject"", 2], [""putobject"", ""mimic""], [""putiseq"", [ ""YARVInstructionSequence/SimpleDataFormat"", 1, 1, 1, {arg_size:1, local_size:2, stack_max:1}, ""mimic"", """", ""method"", [""a""], 1, [], [ [""getlocal"", 2], [""leave""], ] ] ], [""send"", ""core#define_method"", 3, rc.Qnil, 0, rc.Qnil], [""pop""], [""putspecialobject"", 1], [""putspecialobject"", 2], [""putobject"", ""wait""], [""putiseq"", [ ""YARVInstructionSequence/SimpleDataFormat"", 1, 1, 1, {arg_size:0, local_size:1, stack_max:1}, ""wait"", """", ""method"", [], 0, [], [ [""putstring"", ""done waiting""], [""leave""], ] ] ], [""send"", ""core#define_method"", 3, rc.Qnil, 0, rc.Qnil], [""pop""], [""putnil""], [""putnil""], [""putstring"", ""wait 5""], [""send"", ""mimic"", 1, rc.Qnil, 8, rc.Qnil], [""send"", ""puts"", 1, rc.Qnil, 8, rc.Qnil], [""pop""], [""putnil""], [""putnil""], [""send"", ""wait"", 0, rc.Qnil, 8, rc.Qnil], [""send"", ""puts"", 1, rc.Qnil, 8, rc.Qnil], [""pop""], [""putspecialobject"", 1], [""putspecialobject"", 2], [""putobject"", ""col""], [""putiseq"", [ ""YARVInstructionSequence/SimpleDataFormat"", 1, 1, 1, {arg_size:0, local_size:1, stack_max:1}, ""col"", """", ""method"", [], 0, [], [ [""putobject"", 65280], [""leave""], ] ] ], [""send"", ""core#define_method"", 3, rc.Qnil, 0, rc.Qnil], [""pop""], ""label_95"", [""getinlinecache"", rc.Qnil, ""label_102""], [""getconstant"", ""Document""], [""setinlinecache"", ""label_95""], ""label_102"", [""send"", ""graphics"", 0, rc.Qnil, 0, rc.Qnil], [""putobject"", 1], [""putobject"", 1], [""putobject"", 1], [""send"", ""lineStyle"", 3, rc.Qnil, 0, rc.Qnil], [""pop""], ""label_123"", [""getinlinecache"", rc.Qnil, ""label_130""], [""getconstant"", ""Document""], [""setinlinecache"", ""label_123""], ""label_130"", [""send"", ""graphics"", 0, rc.Qnil, 0, rc.Qnil], [""putnil""], [""send"", ""col"", 0, rc.Qnil, 24, rc.Qnil], [""send"", ""beginFill"", 1, rc.Qnil, 0, rc.Qnil], [""pop""], ""label_152"", [""getinlinecache"", rc.Qnil, ""label_159""], [""getconstant"", ""Document""], [""setinlinecache"", ""label_152""], ""label_159"", [""send"", ""graphics"", 0, rc.Qnil, 0, rc.Qnil], [""putobject"", 5], [""putobject"", 5], [""putobject"", 105], [""putobject"", 105], [""send"", ""drawRect"", 4, rc.Qnil, 0, rc.Qnil], [""leave""], ] ]; } protected function ruby_func2():Function { return function (f:RubyFrame):void { f.putnil(); f.putstring(""THIS IS A STRING FROM RUBY!!""); f.send(""puts"", 1, f.Qnil, 8, f.Qnil); f.putstring(""put this into local var""); f.setlocal(2); f.putnil(); f.getlocal(2); f.send(""puts"", 1, f.Qnil, 8, f.Qnil); f.putnil(); f.putstring(""This is another string.""); f.send(""puts"", 1, f.Qnil, 8, f.Qnil); f.putspecialobject(2); f.putnil(); var class_iseq:RbISeq = f.rc.class_iseq_from_func(""A"", 0, 1, 1, function(f:RubyFrame):void { f.putspecialobject(1); f.putspecialobject(2); f.putobject(""m""); var m_iseq:RbISeq = f.rc.method_iseq_from_func(""m"", 0, 1, 1, function(f:RubyFrame):void { f.putstring(""RETURNED from A#m""); f.leave(); }); f.putiseq(m_iseq); f.send(""core#define_method"", 3, f.Qnil, 0, f.Qnil); f.putnil(); f.leave(); }); f.defineclass(""A"", class_iseq, 0); f.pop(); f.getinlinecache(f.Qnil, ""label_31""); f.getconstant(""A""); f.setinlinecache(""label_24""); f.send(""new"", 0, f.Qnil, 0, f.Qnil); f.setlocal(2); f.putnil(); f.getlocal(2); f.send(""m"", 0, f.Qnil, 0, f.Qnil); f.send(""puts"", 1, f.Qnil, 8, f.Qnil); // [:leave] f.leave(); }; } } } ",12210,True,3114.319594305867,median "package com.company.assembleegameclient.objects { import com.company.assembleegameclient.map.Camera; import com.company.assembleegameclient.map.Square; import com.company.assembleegameclient.map.mapoverlay.CharacterStatusText; import com.company.assembleegameclient.objects.particles.HealingEffect; import com.company.assembleegameclient.objects.particles.LevelUpEffect; import com.company.assembleegameclient.parameters.Parameters; import com.company.assembleegameclient.parameters.Parameters; import com.company.assembleegameclient.sound.SoundEffectLibrary; import com.company.assembleegameclient.tutorial.Tutorial; import com.company.assembleegameclient.tutorial.doneAction; import com.company.assembleegameclient.util.AnimatedChar; import com.company.assembleegameclient.util.ConditionEffect; import com.company.assembleegameclient.util.FameUtil; import com.company.assembleegameclient.util.FreeList; import com.company.assembleegameclient.util.MaskedImage; import com.company.assembleegameclient.util.TextureRedrawer; import com.company.assembleegameclient.util.redrawers.GlowRedrawer; import com.company.util.CachingColorTransformer; import com.company.util.ConversionUtil; import com.company.util.GraphicsUtil; import com.company.util.IntPoint; import com.company.util.MoreColorUtil; import com.company.util.PointUtil; import com.company.util.Trig; import flash.display.BitmapData; import flash.display.GraphicsPath; import flash.display.GraphicsSolidFill; import flash.display.IGraphicsData; import flash.geom.ColorTransform; import flash.geom.Matrix; import flash.geom.Point; import flash.geom.Vector3D; import flash.utils.Dictionary; import flash.utils.getTimer; import kabam.rotmg.assets.services.CharacterFactory; import kabam.rotmg.chat.model.ChatMessage; import kabam.rotmg.constants.ActivationType; import kabam.rotmg.constants.GeneralConstants; import kabam.rotmg.constants.UseType; import kabam.rotmg.core.StaticInjectorContext; import kabam.rotmg.game.model.PotionInventoryModel; import kabam.rotmg.game.signals.AddTextLineSignal; import kabam.rotmg.game.view.components.QueuedStatusText; import kabam.rotmg.messaging.impl.data.StatData; import kabam.rotmg.stage3D.GraphicsFillExtra; import kabam.rotmg.text.model.NumberKey; import kabam.rotmg.text.model.TextKey; import kabam.rotmg.text.view.BitmapTextFactory; import kabam.rotmg.text.view.stringBuilder.LineBuilder; import kabam.rotmg.text.view.stringBuilder.StaticStringBuilder; import kabam.rotmg.text.view.stringBuilder.StringBuilder; import kabam.rotmg.ui.model.TabStripModel; import org.swiftsuspenders.Injector; public class Player extends Character { public static const MS_BETWEEN_TELEPORT:int = 10000; private static const MOVE_THRESHOLD:Number = 0.4; private static const NEARBY:Vector. = new [new Point(0, 0), new Point(1, 0), new Point(0, 1), new Point(1, 1)]; private static const RANK_OFFSET_MATRIX:Matrix = new Matrix(1, 0, 0, 1, 2, 2); private static const NAME_OFFSET_MATRIX:Matrix = new Matrix(1, 0, 0, 1, 20, 1); private static const MIN_MOVE_SPEED:Number = 0.004; private static const MAX_MOVE_SPEED:Number = 0.0096; private static const MIN_ATTACK_MULT:Number = 0.5; private static const MAX_ATTACK_MULT:Number = 2; private static const LOW_HEALTH_CT_OFFSET:int = 128; private static var lowHealthCT:Dictionary = new Dictionary(); public static var empiresCoin_:int = 0; public static var accountType_:int = 0; public static var isAdmin:Boolean = false; public static var isMod:Boolean = false; private static var newP:Point = new Point(); public var petObjectId:int = 0; public var petHpHealingAverageMin:int = 0; public var petHpHealingAverageMax:int = 0; public var petHpHealingAverageBonus:int = 0; public var petMpHealingAverageMin:int = 0; public var petMpHealingAverageMax:int = 0; public var petMpHealingAverageBonus:int = 0; public var petAttackCooldown:int = 0; public var petAttackChance:int = 0; public var petAttackDamageMin:int = 0; public var petAttackDamageMax:int = 0; public var isTrading:Boolean = false; public var xpTimer:int; public var skinId:int; public var skin:AnimatedChar; public var isShooting:Boolean; public var accountId_:String = """"; public var credits_:int = 0; public var tokens_:int = 0; public var numStars_:int = 0; public var fame_:int = 0; public var nameChosen_:Boolean = false; public var currFame_:int = 0; public var nextClassQuestFame_:int = -1; public var guildName_:String = null; public var guildRank_:int = -1; public var isFellowGuild_:Boolean = false; public var breath_:int = -1; public var maxMP_:int = 200; public var mp_:Number = 0; public var nextLevelExp_:int = 1000; public var exp_:int = 0; public var attack_:String = null; public var speed_:String = null; public var dexterity_:String = null; public var vitality_:String = null; public var wisdom_:String = null; public var maxHPBoost_:String = null; public var maxMPBoost_:String = null; public var attackBoost_:String = null; public var defenseBoost_:String = null; public var speedBoost_:String = null; public var vitalityBoost_:String = null; public var wisdomBoost_:String = null; public var dexterityBoost_:String = null; public var xpBoost_:int = 0; public var healthPotionCount_:int = 0; public var magicPotionCount_:int = 0; public var attackMax_:int = 0; public var defenseMax_:int = 0; public var speedMax_:int = 0; public var dexterityMax_:int = 0; public var vitalityMax_:int = 0; public var wisdomMax_:int = 0; public var maxHPMax_:int = 0; public var maxMPMax_:int = 0; public var hasBackpack_:Boolean = false; public var accountType_:int = 0; public var admin_:Boolean = false; public var starred_:Boolean = false; public var ignored_:Boolean = false; public var distSqFromThisPlayer_:Number = 0; protected var rotate_:Number = 0; protected var relMoveVec_:Point = null; protected var moveMultiplier_:Number = 1; public var attackPeriod_:Number = 0; public var attackAmount_:int = 0; public var isDazed_:Boolean = false; public var isBerserk_:Boolean = false; public var minAttackFrequency_:Number = 0; public var maxAttackFrequency_:Number = 0; public var weaponRateOfFire_:Number = 0; public var nextAltAttack_:int = 0; public var nextTeleportAt_:int = 0; public var dropBoost:int = 0; public var tierBoost:int = 0; protected var healingEffect_:HealingEffect = null; protected var nearestMerchant_:Merchant = null; public var isDefaultAnimatedChar:Boolean = true; public var projectileIdSetOverrideNew:String = """"; public var projectileIdSetOverrideOld:String = """"; private var addTextLine:AddTextLineSignal; private var factory:CharacterFactory; private var ip_:IntPoint; private var breathBackFill_:GraphicsSolidFill = null; private var breathBackPath_:GraphicsPath = null; private var breathFill_:GraphicsSolidFill = null; private var breathPath_:GraphicsPath = null; private var hallucinatingMaskedImage_:MaskedImage = null; private var slideVec_:Vector3D; public function Player(_arg1:XML) { this.minAttackFrequency_ = 0.0015; this.maxAttackFrequency_ = 0.008; this.ip_ = new IntPoint(); var _local2:Injector = StaticInjectorContext.getInjector(); this.addTextLine = _local2.getInstance(AddTextLineSignal); this.factory = _local2.getInstance(CharacterFactory); super(_arg1); this.attackMax_ = int(_arg1.Attack.@max); this.defenseMax_ = int(_arg1.Defense.@max); this.speedMax_ = int(_arg1.Speed.@max); this.dexterityMax_ = int(_arg1.Dexterity.@max); this.vitalityMax_ = int(_arg1.HpRegen.@max); this.wisdomMax_ = int(_arg1.MpRegen.@max); this.maxHPMax_ = int(_arg1.MaxHitPoints.@max); this.maxMPMax_ = int(_arg1.MaxMagicPoints.@max); texturingCache_ = new Dictionary(); this.slideVec_ = new Vector3D(); } public static function fromPlayerXML(name:String, playerXML:XML):Player { var _local3:int = int(playerXML.ObjectType); var _local4:XML = ObjectLibrary.xmlLibrary_[_local3]; var _local5:Player = new Player(_local4); _local5.name_ = name; _local5.level_ = int(playerXML.Level); _local5.exp_ = int(playerXML.Exp); _local5.equipment_ = ConversionUtil.toIntVector(playerXML.Equipment); _local5.calculateStatBoosts(); _local5.lockedSlot = new Vector.(_local5.equipment_.length); _local5.maxHP_ = (Parameters.parse(_local5.maxHPBoost_) + int(playerXML.MaxHitPoints)); _local5.hp_ = int(playerXML.HitPoints); _local5.maxMP_ = (Parameters.parse(_local5.maxMPBoost_) + int(playerXML.MaxMagicPoints)); _local5.mp_ = int(playerXML.MagicPoints); _local5.attack_ = (Parameters.parse(_local5.attackBoost_) + int(playerXML.Attack)).toString(); _local5.defense_ = (Parameters.parse(_local5.defenseBoost_) + int(playerXML.Defense)).toString(); _local5.speed_ = (Parameters.parse(_local5.speedBoost_) + int(playerXML.Speed)).toString(); _local5.dexterity_ = (Parameters.parse(_local5.vitalityBoost_) + int(playerXML.Dexterity)).toString(); _local5.vitality_ = (Parameters.parse(_local5.wisdomBoost_) + int(playerXML.HpRegen)).toString(); _local5.wisdom_ = (Parameters.parse(_local5.dexterityBoost_) + int(playerXML.MpRegen)).toString(); _local5.tex1Id_ = int(playerXML.Tex1); _local5.tex2Id_ = int(playerXML.Tex2); _local5.hasBackpack_ = int(playerXML.HasBackpack) != 0; return (_local5); } public function calculateStatBoosts():void { var _local2:int; var _local3:XML; var _local4:XML; var _local5:int; var _local6:int; this.maxHPBoost_ = ""0""; this.maxMPBoost_ = ""0""; this.attackBoost_ = ""0""; this.defenseBoost_ = ""0""; this.speedBoost_ = ""0""; this.vitalityBoost_ = ""0""; this.wisdomBoost_ = ""0""; this.dexterityBoost_ = ""0""; var _local1:uint; while (_local1 < GeneralConstants.NUM_EQUIPMENT_SLOTS) { if (((equipment_) && ((equipment_.length > _local1)))) { _local2 = equipment_[_local1]; if (_local2 != -1) { _local3 = ObjectLibrary.xmlLibrary_[_local2]; if (((!((_local3 == null))) && (_local3.hasOwnProperty(""ActivateOnEquip"")))) { for each (_local4 in _local3.ActivateOnEquip) { if (_local4.toString() == ""IncrementStat"") { _local5 = int(_local4.@stat); _local6 = int(_local4.@amount); switch (_local5) { case StatData.MAX_HP_STAT: this.maxHPBoost_ = (this.maxHPBoost_ + _local6); break; case StatData.MAX_MP_STAT: this.maxMPBoost_ = (this.maxMPBoost_ + _local6); break; case StatData.ATTACK_STAT: this.attackBoost_ = (Parameters.parse(this.attackBoost_) + _local6).toString(); break; case StatData.DEFENSE_STAT: this.defenseBoost_ = (Parameters.parse(this.defenseBoost_) + _local6).toString(); break; case StatData.SPEED_STAT: this.speedBoost_ = (Parameters.parse(this.speedBoost_) + _local6).toString(); break; case StatData.VITALITY_STAT: this.vitalityBoost_ = (Parameters.parse(this.vitalityBoost_) + _local6).toString(); break; case StatData.WISDOM_STAT: this.wisdomBoost_ = (Parameters.parse(this.wisdomBoost_) + _local6).toString(); break; case StatData.DEXTERITY_STAT: this.dexterityBoost_ = (Parameters.parse(this.dexterityBoost_) + _local6).toString(); break; } } } } } } _local1++; } } public function setRelativeMovement(_arg1:Number, _arg2:Number, _arg3:Number):void { var _local4:Number; if (this.relMoveVec_ == null) { this.relMoveVec_ = new Point(); } this.rotate_ = _arg1; this.relMoveVec_.x = _arg2; this.relMoveVec_.y = _arg3; if (isConfused()) { _local4 = this.relMoveVec_.x; this.relMoveVec_.x = -(this.relMoveVec_.y); this.relMoveVec_.y = -(_local4); this.rotate_ = -(this.rotate_); } } public function setCredits(_arg1:int):void { this.credits_ = _arg1; } public function setTokens(_arg1:int):void { this.tokens_ = _arg1; } public function setGuildName(_arg1:String):void { var _local3:GameObject; var _local4:Player; var _local5:Boolean; this.guildName_ = _arg1; var _local2:Player = map_.player_; if (_local2 == this) { for each (_local3 in map_.goDict_) { _local4 = (_local3 as Player); if (((!((_local4 == null))) && (!((_local4 == this))))) { _local4.setGuildName(_local4.guildName_); } } } else { _local5 = ((((((!((_local2 == null))) && (!((_local2.guildName_ == null))))) && (!((_local2.guildName_ == """"))))) && ((_local2.guildName_ == this.guildName_))); if (_local5 != this.isFellowGuild_) { this.isFellowGuild_ = _local5; nameBitmapData_ = null; } } } public function isTeleportEligible(_arg1:Player):Boolean { return (!(((_arg1.isPaused()) || (_arg1.isInvisible())))); } public function msUtilTeleport():int { var _local1:int = getTimer(); return (Math.max(0, (this.nextTeleportAt_ - _local1))); } public function teleportTo(_arg1:Player):Boolean { if (isPaused()) { this.addTextLine.dispatch(this.makeErrorMessage(TextKey.PLAYER_NOTELEPORTWHILEPAUSED)); return (false); } var _local2:int = this.msUtilTeleport(); if (_local2 > 0) { this.addTextLine.dispatch(this.makeErrorMessage(TextKey.PLAYER_TELEPORT_COOLDOWN, {""seconds"": int(((_local2 / 1000) + 1))})); return (false); } if (!this.isTeleportEligible(_arg1)) { if (_arg1.isInvisible()) { this.addTextLine.dispatch(this.makeErrorMessage(TextKey.TELEPORT_INVISIBLE_PLAYER, {""player"": _arg1.name_})); } else { this.addTextLine.dispatch(this.makeErrorMessage(TextKey.PLAYER_TELEPORT_TO_PLAYER, {""player"": _arg1.name_})); } return (false); } map_.gs_.gsc_.playerText(""/teleport "" + _arg1.name_); this.nextTeleportAt_ = (getTimer() + MS_BETWEEN_TELEPORT); return (true); } private function makeErrorMessage(_arg1:String, _arg2:Object = null):ChatMessage { return (ChatMessage.make(Parameters.ERROR_CHAT_NAME, _arg1, -1, -1, """", false, _arg2)); } public function levelUpEffect(_arg1:String, _arg2:Boolean = true):void { if (_arg2) { this.levelUpParticleEffect(); } var _local3:QueuedStatusText = new QueuedStatusText(this, new LineBuilder().setParams(_arg1), 0xFF00, 2000); map_.mapOverlay_.addQueuedText(_local3); } public function handleLevelUp(_arg1:Boolean):void { SoundEffectLibrary.play(""level_up""); if (_arg1) { this.levelUpEffect(TextKey.PLAYER_NEWCLASSUNLOCKED, false); this.levelUpEffect(TextKey.PLAYER_LEVELUP); } else { this.levelUpEffect(TextKey.PLAYER_LEVELUP); } } public function levelUpParticleEffect(_arg1:uint = 0xFF00FF00):void { map_.addObj(new LevelUpEffect(this, _arg1, 20), x_, y_); } public function handleExpUp(_arg1:int):void { if (level_ == 20) { return; } var _local2:CharacterStatusText = new CharacterStatusText(this, 0xFF00, 1000); _local2.setStringBuilder(new LineBuilder().setParams(TextKey.PLAYER_EXP, {""exp"": _arg1})); map_.mapOverlay_.addStatusText(_local2); } private function getNearbyMerchant():Merchant { var _local3:Point; var _local4:Merchant; var _local1:int = ((((x_ - int(x_))) > 0.5) ? 1 : -1); var _local2:int = ((((y_ - int(y_))) > 0.5) ? 1 : -1); for each (_local3 in NEARBY) { this.ip_.x_ = (x_ + (_local1 * _local3.x)); this.ip_.y_ = (y_ + (_local2 * _local3.y)); _local4 = map_.merchLookup_[this.ip_]; if (_local4 != null) { return ((((PointUtil.distanceSquaredXY(_local4.x_, _local4.y_, x_, y_) < 1)) ? _local4 : null)); } } return (null); } public function walkTo(_arg1:Number, _arg2:Number):Boolean { this.modifyMove(_arg1, _arg2, newP); return (this.moveTo(newP.x, newP.y)); } override public function moveTo(_arg1:Number, _arg2:Number):Boolean { var _local3:Boolean = super.moveTo(_arg1, _arg2); if (map_.gs_.evalIsNotInCombatMapArea()) { this.nearestMerchant_ = this.getNearbyMerchant(); } return (_local3); } public function modifyMove(_arg1:Number, _arg2:Number, _arg3:Point):void { if (((isParalyzed()) || (isPetrified()))) { _arg3.x = x_; _arg3.y = y_; return; } var _local4:Number = (_arg1 - x_); var _local5:Number = (_arg2 - y_); if ((((((((_local4 < MOVE_THRESHOLD)) && ((_local4 > -(MOVE_THRESHOLD))))) && ((_local5 < MOVE_THRESHOLD)))) && ((_local5 > -(MOVE_THRESHOLD))))) { this.modifyStep(_arg1, _arg2, _arg3); return; } var _local6:Number = (MOVE_THRESHOLD / Math.max(Math.abs(_local4), Math.abs(_local5))); var _local7:Number = 0; _arg3.x = x_; _arg3.y = y_; var _local8:Boolean; while (!(_local8)) { if ((_local7 + _local6) >= 1) { _local6 = (1 - _local7); _local8 = true; } this.modifyStep((_arg3.x + (_local4 * _local6)), (_arg3.y + (_local5 * _local6)), _arg3); _local7 = (_local7 + _local6); } } public function modifyStep(_arg1:Number, _arg2:Number, _arg3:Point):void { var _local6:Number; var _local7:Number; var _local4:Boolean = ((((((x_ % 0.5) == 0)) && (!((_arg1 == x_))))) || (!((int((x_ / 0.5)) == int((_arg1 / 0.5)))))); var _local5:Boolean = ((((((y_ % 0.5) == 0)) && (!((_arg2 == y_))))) || (!((int((y_ / 0.5)) == int((_arg2 / 0.5)))))); if (((((!(_local4)) && (!(_local5)))) || (this.isValidPosition(_arg1, _arg2)))) { _arg3.x = _arg1; _arg3.y = _arg2; return; } if (_local4) { _local6 = (((_arg1) > x_) ? (int((_arg1 * 2)) / 2) : (int((x_ * 2)) / 2)); if (int(_local6) > int(x_)) { _local6 = (_local6 - 0.01); } } if (_local5) { _local7 = (((_arg2) > y_) ? (int((_arg2 * 2)) / 2) : (int((y_ * 2)) / 2)); if (int(_local7) > int(y_)) { _local7 = (_local7 - 0.01); } } if (!_local4) { _arg3.x = _arg1; _arg3.y = _local7; if (((!((square_ == null))) && (!((square_.props_.slideAmount_ == 0))))) { this.resetMoveVector(false); } return; } if (!_local5) { _arg3.x = _local6; _arg3.y = _arg2; if (((!((square_ == null))) && (!((square_.props_.slideAmount_ == 0))))) { this.resetMoveVector(true); } return; } var _local8:Number = (((_arg1) > x_) ? (_arg1 - _local6) : (_local6 - _arg1)); var _local9:Number = (((_arg2) > y_) ? (_arg2 - _local7) : (_local7 - _arg2)); if (_local8 > _local9) { if (this.isValidPosition(_arg1, _local7)) { _arg3.x = _arg1; _arg3.y = _local7; return; } if (this.isValidPosition(_local6, _arg2)) { _arg3.x = _local6; _arg3.y = _arg2; return; } } else { if (this.isValidPosition(_local6, _arg2)) { _arg3.x = _local6; _arg3.y = _arg2; return; } if (this.isValidPosition(_arg1, _local7)) { _arg3.x = _arg1; _arg3.y = _local7; return; } } _arg3.x = _local6; _arg3.y = _local7; } private function resetMoveVector(_arg1:Boolean):void { moveVec_.scaleBy(-0.5); if (_arg1) { moveVec_.y = (moveVec_.y * -1); } else { moveVec_.x = (moveVec_.x * -1); } } public function isValidPosition(_arg1:Number, _arg2:Number):Boolean { var _local3:Square = map_.getSquare(_arg1, _arg2); if (((!((square_ == _local3))) && ((((_local3 == null)) || (!(_local3.isWalkable())))))) { return (false); } var _local4:Number = (_arg1 - int(_arg1)); var _local5:Number = (_arg2 - int(_arg2)); if (_local4 < 0.5) { if (this.isFullOccupy((_arg1 - 1), _arg2)) { return (false); } if (_local5 < 0.5) { if (((this.isFullOccupy(_arg1, (_arg2 - 1))) || (this.isFullOccupy((_arg1 - 1), (_arg2 - 1))))) { return (false); } } else { if (_local5 > 0.5) { if (((this.isFullOccupy(_arg1, (_arg2 + 1))) || (this.isFullOccupy((_arg1 - 1), (_arg2 + 1))))) { return (false); } } } } else { if (_local4 > 0.5) { if (this.isFullOccupy((_arg1 + 1), _arg2)) { return (false); } if (_local5 < 0.5) { if (((this.isFullOccupy(_arg1, (_arg2 - 1))) || (this.isFullOccupy((_arg1 + 1), (_arg2 - 1))))) { return (false); } } else { if (_local5 > 0.5) { if (((this.isFullOccupy(_arg1, (_arg2 + 1))) || (this.isFullOccupy((_arg1 + 1), (_arg2 + 1))))) { return (false); } } } } else { if (_local5 < 0.5) { if (this.isFullOccupy(_arg1, (_arg2 - 1))) { return (false); } } else { if (_local5 > 0.5) { if (this.isFullOccupy(_arg1, (_arg2 + 1))) { return (false); } } } } } return (true); } public function isFullOccupy(_arg1:Number, _arg2:Number):Boolean { var _local3:Square = map_.lookupSquare(_arg1, _arg2); return ((((((_local3 == null)) || ((_local3.tileType_ == 0xFF)))) || (((!((_local3.obj_ == null))) && (_local3.obj_.props_.fullOccupy_))))); } override public function update(currentTime:int, deltaMS:int):Boolean { if (this.tierBoost && !isPaused()) { this.tierBoost = this.tierBoost - deltaMS; if (this.tierBoost < 0) { this.tierBoost = 0; } } if (this.dropBoost && !isPaused()) { this.dropBoost = this.dropBoost - deltaMS; if (this.dropBoost < 0) { this.dropBoost = 0; } } if (this.xpTimer && !isPaused()) { this.xpTimer = this.xpTimer - deltaMS; if (this.xpTimer < 0) { this.xpTimer = 0; } } if (isHealing() && !isPaused()) { if (this.healingEffect_ == null) { this.healingEffect_ = new HealingEffect(this); map_.addObj(this.healingEffect_, x_, y_); } } else { if (this.healingEffect_ != null) { map_.removeObj(this.healingEffect_.objectId_); this.healingEffect_ = null; } } var angle:Number = Parameters.data_.cameraAngle; if (this.rotate_ != 0) { angle = angle + deltaMS * Parameters.PLAYER_ROTATE_SPEED * this.rotate_; Parameters.data_.cameraAngle = angle; } if (map_.player_ == this && isPaused()) { return true; } if (this.relMoveVec_ != null) { if (this.relMoveVec_.x != 0 || this.relMoveVec_.y != 0) { var mvSpd:Number = this.getMoveSpeed(); var mvAngle:Number = Math.atan2(this.relMoveVec_.y, this.relMoveVec_.x); if (square_.props_.slideAmount_ > 0) { slideVec_.x = mvSpd * Math.cos(angle + mvAngle); slideVec_.y = mvSpd * Math.sin(angle + mvAngle); slideVec_.z = 0; moveVec_.scaleBy(square_.props_.slideAmount_); if (moveVec_.length < slideVec_.length) { slideVec_.scaleBy(1 - square_.props_.slideAmount_); moveVec_ = moveVec_.add(slideVec_); } } else { moveVec_.x = mvSpd * Math.cos(angle + mvAngle); moveVec_.y = mvSpd * Math.sin(angle + mvAngle); } } else { if (moveVec_.length > 0.00012 && square_.props_.slideAmount_ > 0) { moveVec_.scaleBy(square_.props_.slideAmount_); } else { moveVec_.x = 0; moveVec_.y = 0; } } if (square_ != null && square_.props_.push_) { moveVec_.x = moveVec_.x - square_.props_.animate_.dx_ / 1000; moveVec_.y = moveVec_.y - square_.props_.animate_.dy_ / 1000; } this.walkTo(x_ + deltaMS * moveVec_.x, y_ + deltaMS * moveVec_.y); } else { if (!super.update(currentTime, deltaMS)) { return false; } } if (map_.player_ == this && square_.props_.maxDamage_ > 0 && (square_.lastDamage_ + 500) < currentTime && !isInvincible() && (square_.obj_ == null || !square_.obj_.props_.protectFromGroundDamage_)) { var dmg:int = map_.gs_.gsc_.getNextDamage(square_.props_.minDamage_, square_.props_.maxDamage_); var conditionEffects:Vector. = new Vector.(); conditionEffects.push(ConditionEffect.GROUND_DAMAGE); damage(-1, dmg, conditionEffects, hp_ <= dmg, null); map_.gs_.gsc_.groundDamage(currentTime, x_, y_); square_.lastDamage_ = currentTime; } return true; } public function onMove():void { if (map_ == null) { return; } var _local1:Square = map_.getSquare(x_, y_); if (_local1.props_.sinking_) { sinkLevel_ = Math.min((sinkLevel_ + 1), Parameters.MAX_SINK_LEVEL); this.moveMultiplier_ = (0.1 + ((1 - (sinkLevel_ / Parameters.MAX_SINK_LEVEL)) * (_local1.props_.speed_ - 0.1))); } else { sinkLevel_ = 0; this.moveMultiplier_ = _local1.props_.speed_; } } override protected function makeNameBitmapData():BitmapData { var _local1:StringBuilder = new StaticStringBuilder(name_); var _local2:BitmapTextFactory = StaticInjectorContext.getInjector().getInstance(BitmapTextFactory); var _local3:BitmapData = _local2.make(_local1, 16, this.getNameColor(), true, NAME_OFFSET_MATRIX, true); _local3.draw(FameUtil.numStarsToIcon(this.numStars_), RANK_OFFSET_MATRIX); return (_local3); } private function getNameColor():uint { if (this.isFellowGuild_) { return (Parameters.FELLOW_GUILD_COLOR); } if (this.nameChosen_) { return (Parameters.NAME_CHOSEN_COLOR); } return (0xFFFFFF); } protected function drawBreathBar(_arg1:Vector., _arg2:int):void { var _local7:Number; var _local8:Number; if (this.breathPath_ == null) { this.breathBackFill_ = new GraphicsSolidFill(); this.breathBackPath_ = new GraphicsPath(GraphicsUtil.QUAD_COMMANDS, new Vector.()); this.breathFill_ = new GraphicsSolidFill(2542335); this.breathPath_ = new GraphicsPath(GraphicsUtil.QUAD_COMMANDS, new Vector.()); } if (this.breath_ <= Parameters.BREATH_THRESH) { _local7 = ((Parameters.BREATH_THRESH - this.breath_) / Parameters.BREATH_THRESH); this.breathBackFill_.color = MoreColorUtil.lerpColor(0x545454, 0xFF0000, (Math.abs(Math.sin((_arg2 / 300))) * _local7)); } else { this.breathBackFill_.color = 0x545454; } var _local3:int = 20; var _local4:int = 8; var _local5:int = 6; var _local6:Vector. = (this.breathBackPath_.data as Vector.); _local6.length = 0; _local6.push((posS_[0] - _local3), (posS_[1] + _local4), (posS_[0] + _local3), (posS_[1] + _local4), (posS_[0] + _local3), ((posS_[1] + _local4) + _local5), (posS_[0] - _local3), ((posS_[1] + _local4) + _local5)); _arg1.push(this.breathBackFill_); _arg1.push(this.breathBackPath_); _arg1.push(GraphicsUtil.END_FILL); if (this.breath_ > 0) { _local8 = (((this.breath_ / 100) * 2) * _local3); this.breathPath_.data.length = 0; _local6 = (this.breathPath_.data as Vector.); _local6.length = 0; _local6.push((posS_[0] - _local3), (posS_[1] + _local4), ((posS_[0] - _local3) + _local8), (posS_[1] + _local4), ((posS_[0] - _local3) + _local8), ((posS_[1] + _local4) + _local5), (posS_[0] - _local3), ((posS_[1] + _local4) + _local5)); _arg1.push(this.breathFill_); _arg1.push(this.breathPath_); _arg1.push(GraphicsUtil.END_FILL); } GraphicsFillExtra.setSoftwareDrawSolid(this.breathFill_, true); GraphicsFillExtra.setSoftwareDrawSolid(this.breathBackFill_, true); } override public function draw(_arg1:Vector., _arg2:Camera, _arg3:int):void { if (this != map_.player_) { if(Parameters.data_.hidePlayers){ return; } if (!Parameters.screenShotMode_) { drawName(_arg1, _arg2); } } else { if (this.breath_ >= 0) { this.drawBreathBar(_arg1, _arg3); } } super.draw(_arg1, _arg2, _arg3); } private function getMoveSpeed():Number { if (isSlowed()) { return ((MIN_MOVE_SPEED * this.moveMultiplier_)); } var _local1:Number = (MIN_MOVE_SPEED + ((Parameters.parse(this.speed_) / 75) * (MAX_MOVE_SPEED - MIN_MOVE_SPEED))); if (((isSpeedy()) || (isNinjaSpeedy()))) { _local1 = (_local1 * 1.5); } return ((_local1 * this.moveMultiplier_)); } public function attackFrequency():Number { this.isDazed_ = isDazed(); this.isBerserk_ = isBerserk(); if (this.isDazed_) return this.minAttackFrequency_; var _rateOfFire:Number = this.minAttackFrequency_ + ((Parameters.parse(this.dexterity_) / 75) * (this.maxAttackFrequency_ - this.minAttackFrequency_)); if (this.isBerserk_) _rateOfFire *= 1.5; return (_rateOfFire); } private function attackMultiplier():Number { if (isWeak()) { return (MIN_ATTACK_MULT); } var _local1:Number = (MIN_ATTACK_MULT + ((Parameters.parse(this.attack_) / 75) * (MAX_ATTACK_MULT - MIN_ATTACK_MULT))); if (isDamaging()) { _local1 = (_local1 * 1.5); } return (_local1); } private function makeSkinTexture():void { var _local1:MaskedImage = this.skin.imageFromAngle(0, AnimatedChar.STAND, 0); animatedChar_ = this.skin; texture_ = _local1.image_; mask_ = _local1.mask_; this.isDefaultAnimatedChar = true; } private function setToRandomAnimatedCharacter():void { var _local1:Vector. = ObjectLibrary.hexTransforms_; var _local2:uint = Math.floor((Math.random() * _local1.length)); var _local3:int = _local1[_local2].@type; var _local4:TextureData = ObjectLibrary.typeToTextureData_[_local3]; texture_ = _local4.texture_; mask_ = _local4.mask_; animatedChar_ = _local4.animatedChar_; this.isDefaultAnimatedChar = false; } override protected function getTexture(camera:Camera, currentTime:int):BitmapData { var pos:Number = 0; var action:int = AnimatedChar.STAND; if (this.isShooting || currentTime < (attackStart_ + this.attackPeriod_)) { facing_ = attackAngle_; pos = ((currentTime - attackStart_) % this.attackPeriod_) / this.attackPeriod_; action = AnimatedChar.ATTACK; } else { if (moveVec_.x != 0 || moveVec_.y != 0) { var movPeriod:int = 3.5 / this.getMoveSpeed(); if (moveVec_.y != 0 || moveVec_.x != 0) { facing_ = Math.atan2(moveVec_.y, moveVec_.x); } pos = (currentTime % movPeriod) / movPeriod; action = AnimatedChar.WALK; } } if (this.isHexed()) { this.isDefaultAnimatedChar && this.setToRandomAnimatedCharacter(); } else { if (!this.isDefaultAnimatedChar) { this.makeSkinTexture(); } } var maskImg:MaskedImage; if (camera.isHallucinating_) { maskImg = getHallucinatingMaskedImage(); } else { maskImg = animatedChar_.imageFromFacing(facing_, camera, action, pos); } var tex1Id:int = tex1Id_; var tex2Id:int = tex2Id_; var tex:BitmapData; if (this.nearestMerchant_) { var merchDict:Dictionary = texturingCache_[this.nearestMerchant_]; if (merchDict == null) { texturingCache_[this.nearestMerchant_] = new Dictionary(); } else { tex = merchDict[maskImg]; } tex1Id = this.nearestMerchant_.getTex1Id(tex1Id_); tex2Id = this.nearestMerchant_.getTex2Id(tex2Id_); } else { tex = texturingCache_[maskImg]; } if (tex == null) { tex = TextureRedrawer.resize(maskImg.image_, maskImg.mask_, size_, false, tex1Id, tex2Id); if (this.nearestMerchant_ != null) { texturingCache_[this.nearestMerchant_][maskImg] = tex; } else { texturingCache_[maskImg] = tex; } } if (hp_ < maxHP_ * 0.2) { var intensity:Number = int(Math.abs(Math.sin(currentTime / 200)) * 10) / 10; var ct:ColorTransform = lowHealthCT[intensity]; if (ct == null) { ct = new ColorTransform(1, 1, 1, 1, intensity * LOW_HEALTH_CT_OFFSET, -intensity * LOW_HEALTH_CT_OFFSET, -intensity * LOW_HEALTH_CT_OFFSET); lowHealthCT[intensity] = ct; } tex = CachingColorTransformer.transformBitmapData(tex, ct); } var plrTex:BitmapData = texturingCache_[tex]; if (plrTex == null) { plrTex = GlowRedrawer.outlineGlow(tex, this.glowColor_); texturingCache_[tex] = plrTex; } if (isPaused() || isStasis() || isPetrified()) { plrTex = CachingColorTransformer.filterBitmapData(plrTex, PAUSED_FILTER); } else { if (isInvisible()) { plrTex = CachingColorTransformer.alphaBitmapData(plrTex, 40); } } return plrTex; } private function getHallucinatingMaskedImage():MaskedImage { if (hallucinatingMaskedImage_ == null) { hallucinatingMaskedImage_ = new MaskedImage(getHallucinatingTexture(), null); } return hallucinatingMaskedImage_; } override public function getPortrait():BitmapData { var _local1:MaskedImage; var _local2:int; if (portrait_ == null) { _local1 = animatedChar_.imageFromDir(AnimatedChar.RIGHT, AnimatedChar.STAND, 0); _local2 = ((4 / _local1.image_.width) * 100); portrait_ = TextureRedrawer.resize(_local1.image_, _local1.mask_, _local2, true, tex1Id_, tex2Id_); portrait_ = GlowRedrawer.outlineGlow(portrait_, 0); } return (portrait_); } public function useAltWeapon(_arg1:Number, _arg2:Number, _arg3:int):Boolean { var _local7:XML; var _local8:int; var _local9:Number; var _local10:int; var _local11:int; if ((((map_ == null)) || (isPaused()))) { return (false); } var _local4:int = equipment_[1]; if (_local4 == -1) { return (false); } var _local5:XML = ObjectLibrary.xmlLibrary_[_local4]; if ((((_local5 == null)) || (!(_local5.hasOwnProperty(""Usable""))))) { return (false); } var _local6:Point = map_.pSTopW(_arg1, _arg2); if (_local6 == null) { SoundEffectLibrary.play(""error""); return (false); } for each (_local7 in _local5.Activate) { if (_local7.toString() == ActivationType.TELEPORT) { if (!this.isValidPosition(_local6.x, _local6.y)) { SoundEffectLibrary.play(""error""); return (false); } } } _local8 = getTimer(); if (_arg3 == UseType.START_USE) { if (_local8 < this.nextAltAttack_) { SoundEffectLibrary.play(""error""); return (false); } _local10 = int(_local5.MpCost); if (_local10 > this.mp_) { SoundEffectLibrary.play(""no_mana""); return (false); } _local11 = 500; if (_local5.hasOwnProperty(TextKey.COOLDOWN)) { _local11 = (Number(_local5.Cooldown) * NumberKey.COOLDOWNVALUE); } this.nextAltAttack_ = (_local8 + _local11); map_.gs_.gsc_.useItem(_local8, objectId_, 1, _local4, _local6.x, _local6.y, _arg3, isTrading); if (_local5.Activate == ActivationType.SHOOT) { _local9 = Math.atan2(_arg2, _arg1); this.doShoot(_local4, _local5, (Parameters.data_.cameraAngle + _local9), false); } } else { if (_local5.hasOwnProperty(""MultiPhase"")) { map_.gs_.gsc_.useItem(_local8, objectId_, 1, _local4, _local6.x, _local6.y, _arg3, isTrading); _local10 = int(_local5.MpEndCost); if (_local10 <= this.mp_) { _local9 = Math.atan2(_arg2, _arg1); this.doShoot(_local4, _local5, (Parameters.data_.cameraAngle + _local9), false); } } } return (true); } public function attemptAttackAngle(_arg1:Number):void { this.shoot((Parameters.data_.cameraAngle + _arg1)); } override public function setAttack(_arg1:int, _arg2:Number):void { var _local3:XML = ObjectLibrary.xmlLibrary_[_arg1]; if ((((_local3 == null)) || (!(_local3.hasOwnProperty(TextKey.RATEOFFIRE))))) { return; } var _local4:Number = Number(_local3.RateOfFire); this.attackPeriod_ = ((NumberKey.RATEOFFIREVALUE / this.attackFrequency()) * (NumberKey.RATEOFFIREVALUE / _local4)); super.setAttack(_arg1, _arg2); } private function shoot(angle:Number):void { if (map_ == null || isStunned() || isPaused() || isPetrified()) return; var weapType:int = this.equipment_[0]; if (weapType == -1) return; var weapon:XML = ObjectLibrary.xmlLibrary_[weapType]; var curTime:int = getTimer(); this.weaponRateOfFire_ = Number(weapon.RateOfFire); this.attackPeriod_ = (NumberKey.RATEOFFIREVALUE / this.attackFrequency()) * (NumberKey.RATEOFFIREVALUE / this.weaponRateOfFire_); if (curTime < this.attackStart_ + this.attackPeriod_) return; doneAction(map_.gs_, Tutorial.ATTACK_ACTION); this.attackAngle_ = angle; this.attackStart_ = curTime; this.doShoot(weapType, weapon, attackAngle_, true); } private function doShoot(weaponType:int, weaponXML:XML, attackAngle:Number, isShooting:Boolean):void { var _local11:uint; var _local12:Projectile; var _local13:int; var _local14:int; var _local15:Number; var _local16:int; var arcGap:Number = (weaponXML.hasOwnProperty(TextKey.ARCGAP) ? Number(weaponXML.ArcGap) : NumberKey.ARCGAPVALUE) * Trig.toRadians; var _local8:Number = (arcGap * (this.attackAmount_ - 1)); var _local9:Number = (attackAngle - (_local8 / 2)); this.isShooting = isShooting; this.attackAmount_ = weaponXML.hasOwnProperty(TextKey.NUMPROJECTILES) ? int(weaponXML.NumProjectiles) : NumberKey.NUMPROJECTILESVALUE; var _local10:int; while (_local10 < this.attackAmount_) { _local11 = getBulletId(); _local12 = (FreeList.newObject(Projectile) as Projectile); if (((isShooting) && (!((this.projectileIdSetOverrideNew == """"))))) { _local12.reset(weaponType, 0, objectId_, _local11, _local9, this.attackStart_, this.projectileIdSetOverrideNew, this.projectileIdSetOverrideOld); } else { _local12.reset(weaponType, 0, objectId_, _local11, _local9, this.attackStart_); } _local13 = int(_local12.projProps_.minDamage_); _local14 = int(_local12.projProps_.maxDamage_); _local15 = ((isShooting) ? this.attackMultiplier() : 1); _local16 = (map_.gs_.gsc_.getNextDamage(_local13, _local14) * _local15); _local12.setDamage(_local16); if ((((_local10 == 0)) && (!((_local12.sound_ == null))))) { SoundEffectLibrary.play(_local12.sound_, 0.75, false); } map_.addObj(_local12, (x_ + (Math.cos(attackAngle) * 0.3)), (y_ + (Math.sin(attackAngle) * 0.3))); map_.gs_.gsc_.playerShoot(_local12, this.attackAmount_, this.isDazed_, this.isBerserk_, this.minAttackFrequency_, this.maxAttackFrequency_, this.weaponRateOfFire_); _local9 = (_local9 + arcGap); _local10++; } } public function isHexed():Boolean { return (!(((condition_[ConditionEffect.CE_FIRST_BATCH] & ConditionEffect.HEXED_BIT) == 0))); } public function isInventoryFull():Boolean { if (equipment_ == null) { return (false); } var _local1:int = equipment_.length; var _local2:uint = 4; while (_local2 < _local1) { if (equipment_[_local2] <= 0) { return (false); } _local2++; } return (true); } public function nextAvailableInventorySlot():int { var _local1:int = ((this.hasBackpack_) ? equipment_.length : (equipment_.length - GeneralConstants.NUM_INVENTORY_SLOTS)); var _local2:uint = 4; while (_local2 < _local1) { if (equipment_[_local2] <= 0) { return (_local2); } _local2++; } return (-1); } public function numberOfAvailableSlots():int { var _local1:int = ((this.hasBackpack_) ? equipment_.length : (equipment_.length - GeneralConstants.NUM_INVENTORY_SLOTS)); var _local2:int; var _local3:uint = 4; while (_local3 < _local1) { if (equipment_[_local3] <= 0) { _local2++; } _local3++; } return (_local2); } public function swapInventoryIndex(_arg1:String):int { var _local2:int; var _local3:int; if (!this.hasBackpack_) { return (-1); } if (_arg1 == TabStripModel.BACKPACK) { _local2 = GeneralConstants.NUM_EQUIPMENT_SLOTS; _local3 = (GeneralConstants.NUM_EQUIPMENT_SLOTS + GeneralConstants.NUM_INVENTORY_SLOTS); } else { _local2 = (GeneralConstants.NUM_EQUIPMENT_SLOTS + GeneralConstants.NUM_INVENTORY_SLOTS); _local3 = equipment_.length; } var _local4:uint = _local2; while (_local4 < _local3) { if (equipment_[_local4] <= 0) { return (_local4); } _local4++; } return (-1); } public function getPotionCount(_arg1:int):int { switch (_arg1) { case PotionInventoryModel.HEALTH_POTION_ID: return (this.healthPotionCount_); case PotionInventoryModel.MAGIC_POTION_ID: return (this.magicPotionCount_); } return (0); } public function getTex1():int { return (tex1Id_); } public function getTex2():int { return (tex2Id_); } } } ",12135,False,2139.416262678996,median "/************************************************************************ * Main entry points. * These are functions that are called directly from event handlers. ************************************************************************/ /* TODO: * cut using a polygonal path, not just a single line segment * truly cut - remove one polygon after cutting. Add action buttons for * cut, burn, fold, unfold and cancel. * UI sequences: * cut: (1) press cut button. (2) draw path. (3) press ok or cancel. * (polygons severed) * burn: (1) press burn button. (2) click on a polygon. (polygon burnt). * fold: (1) press crease button. (2) draw single line segment. * (3) select fold up or down and then a polygon or cancel. * unfold: (1) press unfold button - (snowflake is revealed). * Or - unfold one step at a time? * nice touches: iconic buttons and cursor states. * fold/unfold animation. patterned paper? * */ /* * for a production version: remove debugging code (incl. poly id, fold.poly); * merge * flags into bitfield. maybe could optimize the marking algorithm to only * mark polys that do need to be flipped? */ /* init() * Called when the script starts. Creates the paper movieclip that * contains all the polygon data structures. The canvas movieclip exists * only to enforce the proper stacking order (so the cursor will be on top * of the paper). */ function init() { // data structure initialization canvas.polys = []; canvas.zlevels = 1; canvas.fold_level = 0; canvas.next_poly_id = 0; error = false; with (canvas) { var last = new Point(100, 20); var v = new Point(100, 380, last); v = new Point(460, 380, v); v = new Point(460, 20, v); var square = new Poly(); square.points = v; last.next = v; polys.push(square); getModelBounds (polys, true); drawModel (canvas); } colors = new Array (0x444433, 0x554433, 0x663344, 0x446633, 0x333366, 0x666666, 0x884488, 0x992222, 0x229922, 0x222299); } function setCursor (clip) // set (or clear) a custom cursor { if (cursor.cursorclip) cursor.cursorclip._visible = false; if (clip) { Mouse.hide (); cursor.cursorclip = clip; clip._x = _root._xmouse; clip._y = _root._ymouse; clip._visible = true; } else { Mouse.show (); } } function printModel () { print (""canvas"", ""bframe""); } /* foldModel (x1, y1, x2, y2) * * folds (reflects, flips and raises/lowers in stacking order) a set * of polygons intersected by a line segment. Note: there is a problem * with this in that it allows polygons to be folded ""through"" each other. * This can be prevented by requiring the line segment to begin and end * outside the polygons (I think). Or it might be possible to detect the * obstruction of a folding poly by another poly above or below it that is * not being folded. In this case we could either prevent the fold or * possibly ""tuck"" the fold in an interior layer. In any case all that * stuff would require a bunch of expensive geometry. * * Each of the polygons in the model is tested for intersection with the line segment, * and possibly split. * foldPoly will fold polygons using a right-hand rule. * After being split, the halves to the right of the fold line are folded * underneath (they are reflected about the fold line and have their z-value reflected * around the (new) central z value. */ function foldModel (x1, y1, x2, y2) { /* var v1 = { x: x1-1.5, y : y1-2.5 } ; var v2 = { x: x2-1.5, y : y2-2.5 } ; */ var v1 = { x: x1, y : y1 } ; var v2 = { x: x2, y : y2 } ; canvas.globalToLocal (v1); canvas.globalToLocal (v2); v1 = new Point (v1.x, v1.y); v2 = new Point (v2.x, v2.y); // trace (""fold "" + x1 +"","" + y1 + ""->""+x2+"",""+y2); var new_polys = []; var npolys = canvas.polys.length; var i; // trace (""foldModel: "" + npolys ); // dumpPolys (canvas.polys); for (i = 0; i < npolys; i++) { // trace (""splitPoly "" +canvas.polys[i].id); foldPoly (canvas.polys[i], v1, v2, new_polys, canvas.fold_level + 1); /* dumpPolys (canvas.polys); trace (""new polys:""); dumpPolys (new_polys); */ } if (new_polys.length <= 0) return; for (i = 0; i= canvas.fold_level / 2. for (var i=0; i "" + v2.x + "","" + v2.y); canvas.moveTo (v1.x, v1.y); canvas.lineStyle(0, 0x000000, 100); canvas.lineTo (v2.x, v2.y); updateAfterEvent (); var u = null; var v; var treturn = {}; // maybe get all the intersections and just use the closest one? for (v = pcut.points; v; v = v.next && !u) { u = intersectEdges (v1, v2, v, v.next, true, treturn); if (treturn.t <= 0) { u = null; } } // create pcut if it doesn't exist yet if (!pcut) { pcut = new Poly(); pcut.points = v1; } var v = pcut.points; while (v.next) { /* find the end of the poly's linked list */ v = v.next; } if (!u) { // append v2 to pcut v.next = v2; return false; } // cut as soon as we have a closed poly v.next = u; /* append u to p */ // u.next = pcut.points; /* close the poly*/ // ??? u.next = pcut.points.next // eliminate pcut.points to ensure a closed polygon pcut.points = u; cursor.clear (); drawPoly (pcut, canvas); cutModel (); return true; } function cutModel () { // do cutting var npolys = canvas.polys.length; var new_polys = []; var cut_folds = []; var i; var new_new_polys = []; // dumpPolyBrief (pcut); computeBoundingBox (pcut); for (i = 0; i < npolys; i++) { if (! polysOverlap (canvas.polys[i], pcut)) { // a bounding box test continue; } cutPoly (canvas.polys[i], pcut, new_new_polys, cut_folds); computeBoundingBox (canvas.polys[i]); while (new_new_polys.length) { // don't try to cut the new_polys new_polys.push (new_new_polys.pop()); } } for (i = 0; i < new_polys.length; i++) { canvas.polys.push(new_polys[i]); computeBoundingBox (new_polys[i]); } for (i = 0; i < cut_folds.length; i++) { patchCutFold (cut_folds[i]); } getModelBounds (canvas.polys, false); drawModel (canvas); // dumpPolys (canvas.polys) // checkModel (canvas.polys); // clear pcut pcut = null; } /************************************************************************* * drawing functions *************************************************************************/ function drawModel(mc) { mc.clear (); mc.lineStyle(0, 0x000000, 100); // sort in inverse stacking order - draw bottom poly first mc.polys.sort(polyStackComparison); for (var i = 0; i yspan ? (360 / xspan) : (360 / yspan)); var newx = 280 - (canvas.bounds.right + canvas.bounds.left) * scale / 200; var newy = 200 - (canvas.bounds.bottom + canvas.bounds.top) * scale / 200; canvas.scale_delta = (scale-canvas._xscale) / 6; canvas.x_delta = (newx-canvas._x) / 6; canvas.y_delta = (newy-canvas._y) / 6; canvas.rescale_idx = 6; } function drawPoly(p, mc) { var v = p.points; if (! v) return; var scale = 100 / canvas._xscale; mc.moveTo(v.x, v.y); mc.beginFill(p.faceup ? p.fgcolor : 0xaaaaaa, 70); mc.lineStyle(0, 0, 100); do { if (v.fold) canvas.lineStyle(v.fold.level * scale, 0, 100); else if (v.is_crease) { canvas.lineStyle(0, 0, 0); } else { canvas.lineStyle(0, 0, 100); } v = v.next; mc.LineTo(v.x, v.y); } while (v != p.points); mc.endFill(); } function drawDiamond (v, mc, c) { mc.lineStyle(0, 0x000000, 100); mc.beginFill(c, 100); mc.moveTo(v.x-3, v.y); mc.LineTo(v.x, v.y-3); mc.LineTo(v.x+3, v.y); mc.LineTo(v.x, v.y+3); mc.LineTo(v.x-3, v.y); mc.endFill(); } /* * polygon selection */ function findPolygon (x, y) { var v = { x: x, y : y } ; canvas.globalToLocal (v); v = new Point (v.x, v.y); canvas.selectedPoly = null; for (var i = canvas.polys.length - 1; i >= 0; i--) { if (containsPoly(canvas.polys[i], v)) { return canvas.polys[i]; } } } function discardPolygon (x, y) { var p; var found = false; while (p = findPolygon (x, y)) { markPolyTree (p, true, null, 0); for (var i = 0; i < canvas.polys.length; i++) { if (canvas.polys[i].flipme) { var p = canvas.polys[i]; canvas.polys.splice (i, 1); /* remove the poly */ deletePoly (p); --i; found = true; } } } getModelBounds (canvas.polys, false); drawModel (canvas); return found; } function test (x, y) { var v = new Point (x, y); if (containsPoly (canvas.polys[0], v)) { trace (""in""); } else { trace (""out""); } } /************************************************************************ * polygon manipulation: cutting and folding ************************************************************************/ /* * foldPoly splits a polygon in two with a line segment, modifying the * argument p and returning a list of any new polygons that are created. */ function foldPoly (p, v1, v2, new_polys, fold_level) { var intersections = intersectPoly (p, v1, v2); if (intersections.length < 2) { return null; // Ignore snips into the interior that leave the polygon whole } var inp = contains(p, v1); if (inp && intersections.length < 3) { return null; // Ignore snips from the interior to the interior that leave the polygon whole } if (inp) { // ignore the first intersection since it's just incidental if we started inside the polygon intersections.shift(); // TBD delete me? } while (intersections.length > 1) { /* Create a new poly from one side of the cut (or fold) In the new poly, the dividing edge contains the points b, a in the sequence: b0->b->a->a.next. Also modify the existing poly to contain the new edge in the sequence: a0->a->b->b0.next */ var a_int = intersections.shift(); var a = a_int.pt, a0 = a_int.edge; var fa = a0.fold; var b_int = intersections.shift(); var b = b_int.pt, b0 = b_int.edge; var fb = b0.fold; // trace (""foldPoly a=("" + a.x + "","" + a.y + ""), b=("" + b.x + "","" + b.y + "")""); var p1 = copyPoly (p); // clone b and a for the new poly and set up the fold structure linking them // and their polygons together var b1 = copyPoint (b); var a1 = copyPoint (a); var f = new Fold (p, a, b, fold_level); a.fold = f; // b.fold = f; var f1 = new Fold (p1, b1, a1, fold_level); b1.fold = f1; // a1.fold = f1; f1.twin = f; f.twin = f1; // relink the points to form p1 b1.next = a1; a1.next = a0.next; b.next = b0.next; // part of p, not p1 - but do it now to avoid losing the link b0.next = b1; p1.points = b1; new_polys.push (p1); // hook up the p points a0.next = a; a.next = b; p.points = a; // may be redundant, but sometimes needed... // set the poly links of all the points in p and p1 setPointsPoly (p); setPointsPoly (p1); // mark these polys as having determinate flippedness p1.is_anchor = true; p.is_anchor = true; // determine which poly is on the right hand side of the fold and mark it. if (p.faceup) { p.flipme = true; } else { p1.flipme = true; } // I checked via dumpPolys and everything looked good after two folds // - once widthwise and once lengthwise if (fa) { if (fa.v1 != a0 || fa.v2 != a1.next) { trace (""BARF FA""); } foldFold (fa, a, a1); // split the fa fold in two } if (fb) { if (fb.v1 != b0 || fb.v2 != b.next) { trace (""BARF FB""); } foldFold (fb, b1, b); // split the fb fold in two } // dumpPoly (p); // dumpPoly (p1); delete a_int; // unnecessary? delete b_int; } } function foldFold (f, a, a1) { // split the f fold in two var f1 = new Fold (a1.poly, a1, f.v2, f.level); f.v2 = a; // a.fold = f; // no - should be set to the new higher-level fold a1.fold = f1; if (f1.v2.fold == f) /* f.v2.fold is already = f if it should */ f1.v2.fold = f1; if (f.other_twin) { // fa's twin has already been split - it left a ptr in f f1.twin = f.twin; f.twin = f.other_twin; // f.twin.twin = f; -- already? f1.twin.twin = f1; delete f.other_twin; } else { f1.twin = f.twin; /* for now */ f.twin.other_twin = f1; } } /* markPolySubTree */ function markPolySubTree (p, fold_level, parent) { if (p.visited) { // trace ( "" markPoly "" + p.id + "" (already)""); return; // stop this thing from going on forever } p.visited = true; p.flipme = true; // trace ( "" markPoly marking "" + p.id); var v = p.points; do { var f = v.fold; var p1; if (f && (p1 = f.twin.v1.poly) != parent) { if (f.level != fold_level) { // don't cross the fold markPolySubTree (p1, fold_level, p); } } v = v.next; } while (v != p.points); } /* markPolyTree * Walk a graph of polys, following fold_poly links, setting flags */ function markPolyTree (p, flipping, parent, fold_level) { if (p.visited) { // trace ( "" markPoly "" + p.id + "" (already)""); return; // stop this thing from going on forever } p.visited = true; if (p.is_anchor) { // The newly split polygons are like islands of certainty in a sea of doubt... flipping = p.flipme; // trace ("" markPoly "" + p.id + "" new - set flipping to "" + flipping); } else { p.flipme = flipping; // trace ("" markPoly "" + p.id + "" flipme set to "" + flipping); } var v = p.points; do { // recurse through folds, including the current one. // the parent test is not strictly necessary - it just saves some useless recursions var f = v.fold; var p1; if (f && (p1 = f.twin.v1.poly) != parent) { if (f.level == fold_level) { // change flipping when crossing the fold markPolyTree (p1, !flipping, p, fold_level); } else { markPolyTree (p1, flipping, p, fold_level); } } v = v.next; } while (v != p.points); } function cutPoly (p, pcut, new_polys, cut_folds) { var v = pcut.points; var vout = new Point (-100, -100); // trace (""cutPoly "" + p.id); // see if v is inside p (and remember a ""nearby"" intersection) var inside; var outer_xings; do { outer_xings = intersectPoly (p, vout, v); inside = outer_xings.length % 2 == 1; if (! inside) break; v = v.next; } while (v != pcut.points); if (inside) { // there are no external points... // maybe figure this out later // trace ("" inside poly "" + p.id + ""; skipping""); return; } /* if (v != pcut.points) { pcut.points.poly = pcut; var prev = findPrev (pcut.points); prev.next = pcut.points.next; // eliminate the extra tail on the poly pcut.points = v; // start at an outside point } */ pcut.points = v; /* start at an outside point */ var nxings = 0; var xings = []; var pp = null; do { var vxings, min_dist = 2; if (pp) { vxings = intersectPoly (pp, v, v.next); } else { // search for the first poly of our new batch to be intersected by this // line segment vxings = intersectPoly (p, v, v.next); if (vxings.length > 0) { min_dist = vxings[0].t; pp = p; } for (var i = 0; i < new_polys.length; i++) { var pivxings = intersectPoly (new_polys[i], v, v.next); if (pivxings.length > 0 && min_dist > pivxings[0].t) { min_dist = pivxings[0].t; vxings = pivxings; pp = new_polys[i]; // TBD - check to be sure we can break here - don't // we need to check them all? break; } } } var n = vxings.length; nxings += n; if (n % 2) inside = !inside; while (n--) { xings.push (vxings.shift()); } while (nxings >= 2) { cutPolySegment (pp, xings, new_polys, cut_folds); nxings -= 2; } if (inside) { /* no ""edge"" indicates this is not an intersection, but a new interior point // be sure to copy the point because it will be incorporated // into a new polygon and can't be shared by several */ xings.push ( { pt: copyPoint(v.next) } ); } if (xings.length == 0) { pp = null; } v = v.next; } while (v != pcut.points); // now xings has all the intersections of pcut with p plus any points of pcut interior to p. /* if (new_polys.length == 0) { trace (""cutPoly: no new polys?""); } */ for (var i = 0; i < new_polys.length; i++) { setPointsPoly (p); setPointsPoly (new_polys[i]); } } function cutPolySegment (p, xings, new_polys, cut_folds) { // trace (""cutPolySegment "" + p.id); var a, b, a0, b0, a_last, b_last, e, e0; var done = false; // loop over all intersections and internal points, creating new polygons // out of pieces of p. while (xings.length > 0 && !done) { var xing = xings.shift(); a = copyPoint (xing.pt); b = copyPoint (a); if (!a0) { a0 = a; b0 = b; if (!xing.edge) trace (""cutPolySegment: first intersection crosses no edge?""); e0 = xing.edge; } else { a_last.next = a; b.next = b_last; if (xing.edge) done = true; } a_last = a; b_last = b; } // now close off the polygons depending on the relationship of the entry // and exit points - there are three cases: var e = xing.edge; /* (e, e.next) = intersected edge of p */ var p1 = copyPoly (p); new_polys.push (p1); var f = e.fold; // TBD !!!: this edge is sometimes spurious because of the temporary // settings we make during the cutting process (see XXX below) if (e != e0) { // We entered and exited on different edges. // Remember the salient points on the folded edges - before losing // the links e/e.next and e0/e0.next if (f) { pushCutFoldPoint (f, a, p.faceup ? cut_folds : null); a.fold = f; /* XXX */ //b.fold = f; } if (f = e0.fold) { pushCutFoldPoint (f, b0, p.faceup ? cut_folds : null); //a0.fold = f; /* XXX */ b0.fold = f; } // close off the polygons b0.next = e0.next; e0.next = a0; a.next = e.next; e.next = b; } else /* a0,b0 and a,b are on the same edge */ { // If a is further from e0 than a0 then the b's form their own // entirely new polygon, while the a's are connected to the points // of the original p. if ((Math.abs(a.x-e0.x) + Math.abs(a.y-e0.y)) > (Math.abs(a0.x-e0.x) + Math.abs(a0.y-e0.y))) { a.next = e0.next; b0.next = b; e0.next = a0; } else // ... otherwise the a's form the new polygon, and the b's // get connected to p. { a.next = a0; b0.next = e0.next; e0.next = b; } if (f) { a.fold = f; /* XXX */ //a0.fold = f; //b.fold = f; b0.fold = f; pushCutFoldPoint (f, b0, p.faceup ? cut_folds : null); pushCutFoldPoint (f, a); } } p.points = a; p1.points = b; if (!done) trace (""cutPolySegment exiting when ! done?""); } function pushCutFoldPoint (f, v, cutfolds) { if (! f.cutpoints) { f.cutpoints = new Array; if (cutfolds) cutfolds.push (f); } f.cutpoints.push (v); } function patchCutFold (f) { var f1 = f.twin; // sanity check: if (!f.cutpoints || !f1.cutpoints || f.cutpoints.length != f1.cutpoints.length) { trace (""patchCutFold: fold mismatch detected""); trace (""patchCutFold: f has "" + f.cutpoints.length + "", f1 has "" + f1.cutpoints.length); trace (""patchCutFold: f=("" + Math.round(f.v1.x)+"",""+Math.round(f.v1.y)+""),(""+ Math.round(f.v2.x)+"",""+Math.round(f.v2.y)+"")"" + "" f1=("" + Math.round(f1.v1.x)+"",""+Math.round(f1.v1.y)+""),(""+ Math.round(f1.v2.x)+"",""+Math.round(f1.v2.y)+"")"" ); drawDiamond (f.v1, cursor, 0xff0000); drawDiamond (f.v2, cursor, 0xff0000); drawDiamond (f1.v1, cursor, 0x0000ff); drawDiamond (f1.v2, cursor, 0x0000ff); for (var i=0; i 0) { var v = f.cutpoints.pop(); var v1; if (v.next == f.v2) { // the start point of the original uncut folded edge f1 // is added implicitly v1 = f1.v1; } else { // search for the matching point in f1's cutpoints var i; v1 = null; for (i=0; i 0) { trace (""patchCutFold: cutpoints left over in f1""); } } function addCutFold (v, v1, f, f1) { var ff = new Fold (v.poly, v, v.next, f.level); // if (!v.fold || v.fold == f) v.fold = ff; // if (!v.next.fold || v.next.fold == f) // v.next.fold = ff; var ff1 = new Fold (v1.poly, v1, v1.next, f1.level); // if (!v1.fold || v1.fold == f1) v1.fold = ff1; // if (!v1.next.fold || v1.next.fold == f1) // v1.next.fold = ff1; ff.twin = ff1; ff1.twin = ff; // twinned points must be co-located if (!peq(v, v1.next) || !peq(v1, v.next)) { trace (""patchCutFold: fold point mismatch, f=("" + Math.round(v.x)+"",""+Math.round(v.y)+""),(""+ Math.round(v.next.x)+"",""+Math.round(v.next.y)+"")"" + "" f1=("" + Math.round(v1.x)+"",""+Math.round(v1.y)+""),(""+ Math.round(v1.next.x)+"",""+Math.round(v1.next.y)+"")"" ); drawDiamond (v, cursor, 0xff0000); drawDiamond (v.next, cursor, 0xff0000); drawDiamond (v1, cursor, 0x0000ff); drawDiamond (v1.next, cursor, 0x0000ff); error = true; } } function clearPolyFlags (polys) { for (i = 0; iv1.next, set the z value and flip the * polygon's orientation. */ function reflectPoly (p, v1, v2, zlevels) { var d2 = distanceSquared (v1, v2); if (d2 <= 0.01) return; var x21 = v2.x - v1.x; var y21 = v2.y - v1.y; var v = p.points; do { // loop over all the points in the polygon , compute the value of t // that describes the closest point on the edge (v1, v2) to the // point v, where the line is written v1 + t(v2-v1). Then the new // reflected point v' is 2 (v1 + t(v2-v1)) - v // // however if the point lies on the reflection edge then skip it if (v == v1 || v == v2) { v = v.next; continue; } var t = ((v.x - v1.x) * x21 + (v.y - v1.y) * y21) / d2; v.x = 2 * (v1.x + t * (v2.x - v1.x)) - v.x; v.y = 2 * (v1.y + t * (v2.y - v1.y)) - v.y; v = v.next; } while (v != p.points); p.z = zlevels - p.z - 1; // reflect the z-value about the midpoint p.faceup = !p.faceup; // flip the poly over } /************************************************************************ * basic polygon geometry and intersection calculations ************************************************************************/ function distanceSquared (u, v) { var dx = (u.x - v.x), dy = (u.y - v.y); return dx*dx + dy*dy; } /* * rhsTest * checks which side of (x1,y1)->(x2, y2) (x,y) is on; returns * a boolean indicating whether it's on the rhs (or on the line itself). */ function rhsTest (x1, y1, x2, y2, x, y) { var px = x - x1; var py = y - y1; var rx = x2 - x1; var ry = y2 - y1; return (px*ry - py*rx) <= 0 ? true : false; } /* * containsPoly * returns a boolean indicating whether a point lies inside a polygon. Determined by * drawing a line from a point known to be outside the polygon to the point in question. * If the number of intersections of the resulting line segment with the polygon is odd * then the point lies inside the polygon, otherwise it's outside. */ function containsPoly (p, v) { if (v.x < p.ul.x || v.x > p.br.x || v.y < p.ul.y || v.y > p.br.y) return false; var vout = new Point (-100, -100); var u = p.points; var intCount; do { if (intersectEdges (vout, v, u, u.next, false)) { ++intCount; } u = u.next; } while (u != p.points) return intCount % 2 == 1 ; } /* * intersectPoly * Returns an array of intersections of a line segment and a polygon, * sorted by distance from the start point of the line segment. * The array contains structs with three elements; * pt: the point of intersection * edge: the first point on the polygon of the edge on which the intersection lies. * t: parameter values of the line equation (v1 + t *(v2-v1)); used to order the points * If there is no intersection, an empty list is returned. */ function intersectPoly (p, v1, v2) { var result = []; var param = { }; /* use for function return value since this language has no explicit references */ var u = p.points; do { var v = intersectEdges (v1, v2, u, u.next, true, param); if (v) { var i; for (i=0; i param.t) { break; } } result.splice (i, 0, {pt: v, edge: u, t : param.t}); } u = u.next; } while (u != p.points); return result; } function intersectEdges (v1, v2, u1, u2, returnPoint, returnParam) // test for intersection of line segment e with line segment formed by // points[i],points[i+1] // // If returnPoint is true, the intersection point is returned, // otherwise simply a Boolean indicating whether or not there is an // intersection { // TBD: an overall speedup may result from this bounding box test if (! rectOverlap (u1, u2, v1, v2)) return null; var x43 = u2.x - u1.x; var y43 = u2.y - u1.y; var x21 = v2.x - v1.x; var y21 = v2.y - v1.y; var denom = y43*x21 - x43*y21; if (Math.abs(denom) < 0.01) { return null; // line segments are parallel } var x13 = v1.x - u1.x; var y13 = v1.y - u1.y; var t12 = (x43*y13 - y43*x13) / denom; if (returnParam) { returnParam.t = t12 }; if (t12 > 1.0 || t12 < 0.0) { return null; // intersection lies off of line segment e } var t34 = (x21*y13 - y21*x13) / denom; if (t34 > 1.0 || t34 < 0.0) { return null; // intersection lies off of line segment p(i,j) } // found an intersection - return the point return returnPoint ? new Point (v1.x + t12 * x21, v1.y + t12 * y21) : true; } /********************************************************************** * little utilities **********************************************************************/ function polyStackComparison(v1, v2) { return v2.z-v1.z; } function findPrev (v) { var u = v.poly.points; while (u.next != v) { u = u.next; } return u; } function setPointsPoly (p) { var u = p.points; do { u.poly = p; u = u.next; } while (u != p.points) ; } function rectOverlap (u1, u2, v1, v2) { if (v2.x > v1.x) { if (u1.x > v2.x) { if (u2.x > v2.x) { return null; } } else if (u1.x < v1.x) { if (u2.x < v1.x) { return null; } } } else { if (u1.x < v2.x) { if (u2.x < v2.x) { return null; } } else if (u1.x > v1.x) { if (u2.x > v1.x) { return null; } } } if (v2.y > v1.y) { if (u1.y > v2.y) { if (u2.y > v2.y) { return null; } } else if (u1.y < v1.y) { if (u2.y < v1.y) { return null; } } } else { if (u1.y < v2.y) { if (u2.y < v2.y) { return null; } } else if (u1.y > v1.y) { if (u2.y > v1.y) { return null; } } } return true; } function polysOverlap (p1, p2) { if (p1.ul.x > p2.br.x || p2.ul.x > p1.br.x || p1.ul.y > p2.br.y || p2.ul.y > p1.br.y) { return false; } return true; } function getModelBounds (polys, descend) { var left=1000, right=-1000, top=1000, bottom=-1000; for (var i =0; i right) right = p.br.x; if (p.ul.y < top) top = p.ul.y; if (p.br.y > bottom) bottom = p.br.y; } canvas.bounds = { left: left, top: top, bottom: bottom, right: right }; } function computeBoundingBox (p) { var left=1000, right=-1000, top=1000, bottom=-1000; var u = p.points; do { if (u.x < left) left = u.x; if (u.x > right) right = u.x; if (u.y > bottom) bottom = u.y; if (u.y < top) top = u.y; u = u.next; } while (u != p.points); if (p.ul) { p.ul.x = left; p.ul.y = top; p.br.x = right; p.br.y = bottom; } else { p.ul = new Point (left, top); p.br = new Point (right, bottom); } } /* function dumpPolys (polys) { for (var i =0; i 100) { trace (""WARNING: poly has > 100 points? possible inf. loop detected""); break; } } while (u != p.points); } } */ /********************************************************************** * data structure functions; constructors, copiers, etc. **********************************************************************/ function Point(x, y, v) { this.x = x; this.y = y; this.next = v; return this; // this.poly = p; } function copyPoint (v) { var u = new Point (v.x, v.y); return u; } function peq (v, v1) { return (Math.abs (v.x-v1.x) < 0.0001 && Math.abs (v.y-v1.y) < 0.0001); } function deletePoint (v) { if (v.fold && v == v.fold.v1) { delete v.fold; } delete v; } function Poly() { this.points = null; this.z = 0; this.faceup = true; this.fgcolor = 0xdddddd; // These three flags are used to keep track of which polygons are to be // flipped when folding - we might combine them into a bit field... this.flipme = false; this.visited = false; this.is_anchor = false; this.id = canvas.next_poly_id++; return this; } function copyPoly (p) { var new_poly = new Poly (); new_poly.z = p.z; new_poly.faceup = p.faceup; new_poly.fgcolor = colors[new_poly.id % colors.length]; return new_poly; } function deletePoly (p) { var v = p.points; var u = v.next; v.next = null; while (u) { var v = u.next; deletePoint (u); u = v; } delete p; } function Fold (p, v1, v2, level) { this.v1 = v1; this.v2 = v2; this.level = level; this.twin = null; return this; } ",12544,False,2108.3912666370243,median "//////////////////////////////////////////////////////////////////////////////// // // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the ""License""); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an ""AS IS"" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// package mx.controls { COMPILE::JS { import goog.events; import org.apache.royale.core.WrappedHTMLElement; import org.apache.royale.html.util.addElementToWrapper; } import mx.controls.listClasses.BaseListData; import mx.core.ITextInput; import mx.core.UIComponent; import mx.events.FlexEvent; import org.apache.royale.core.ITextModel; import org.apache.royale.events.Event; import org.apache.royale.html.accessories.PasswordInputBead; import org.apache.royale.html.beads.DisableBead; COMPILE::SWF { import org.apache.royale.html.beads.TextInputView; } /* import mx.managers.IFocusManager; import mx.managers.IFocusManagerComponent; import mx.managers.ISystemManager; import mx.managers.SystemManager; import mx.styles.ISimpleStyleClient; use namespace mx_internal; */ //-------------------------------------- // Events //-------------------------------------- /** * Dispatched when text in the TextInput control changes * through user input. * This event does not occur if you use data binding or * ActionScript code to change the text. * *

Even though the default value of the Event.bubbles property * is true, this control dispatches the event with * the Event.bubbles property set to false.

* * @eventType flash.events.Event.CHANGE * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Event(name=""change"", type=""flash.events.Event"")] /** * Dispatched when the data property changes. * *

When you use a component as an item renderer, * the data property contains the data to display. * You can listen for this event and update the component * when the data property changes.

* * @eventType mx.events.FlexEvent.DATA_CHANGE * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Event(name=""dataChange"", type=""mx.events.FlexEvent"")] /** * Dispatched when the user presses the Enter key. * * @eventType mx.events.FlexEvent.ENTER * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Event(name=""enter"", type=""mx.events.FlexEvent"")] /** * Dispatched when the user types, deletes, or pastes text into the control. * No event is dispatched when the user presses the Delete key, or Backspace key. * *

Even though the default value of the TextEvent.bubbles property * is true, this control dispatches the event with * the TextEvent.bubbles property set to false.

* * @eventType flash.events.TextEvent.TEXT_INPUT * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Event(name=""textInput"", type=""flash.events.TextEvent"")] //-------------------------------------- // Other metadata //-------------------------------------- [DefaultBindingProperty(source=""text"", destination=""text"")] [DefaultTriggerEvent(""change"")] /** * The TextInput control is a single-line text field * that is optionally editable. * All text in this control must use the same styling * unless it is HTML text. * The TextInput control supports the HTML rendering * capabilities of Flash Player and AIR. * *

TextInput controls do not include a label, although you * can add one by using a Label control or by nesting the * TextInput control in a FormItem control in a Form container. * When used in a FormItem control, a TextInput control * indicates whether a value is required. * TextInput controls have a number of states, including filled, * selected, disabled, and error. * TextInput controls support formatting, validation, and keyboard * equivalents; they also dispatch change and enter events.

* *

If you disable a TextInput control, it displays its contents * in the color specified by the disabledColor * style. * To disallow editing the text, you set the editable * property to false. * To conceal the input text by displaying asterisks instead of the * characters entered, you set the displayAsPassword property * to true.

* *

The TextInput control is used as a subcomponent in several other controls, * such as the RichTextEditor, NumericStepper, and ComboBox controls. As a result, * if you assign style properties to a TextInput control by using a CSS type selector, * Flex applies those styles to the TextInput when it appears in the other controls * unless you explicitly override them.

* *

The TextInput control has the following default sizing characteristics:

* * * * * * * * * * * * * * * * * *
CharacteristicDescription
Default sizeThe size of the text with a default minimum size of 22 pixels high and 160 pixels wide
Minimum size0 pixels
Maximum size10000 by 10000 pixels
* * @mxml * *

The <mx:TextInput> tag inherits the attributes * of its superclass and adds the following attributes:

* *
 *  <mx:TextInput
 *    Properties
 *    condenseWhite=""false|true""
 *    data=""undefined""
 *    displayAsPassword=""false|true""
 *    editable=""true|false""
 *    horizontalScrollPosition=""0""
 *    htmlText=""""
 *    imeMode=""null""
 *    length=""0""
 *    listData=""null""
 *    maxChars=""0""
 *    parentDrawsFocus=""false""
 *    restrict=""null""
 *    selectionBeginIndex=""0""
 *    selectionEndIndex=""0""
 *    text=""""
 *    textHeight=""0""
 *    textWidth=""0""
 *     
 *    Styles
 *    backgroundAlpha=""1.0""
 *    backgroundColor=""undefined""
 *    backgroundImage=""undefined""
 *    backgroundSize=""auto""
 *    borderColor=""0xAAB3B3""
 *    borderSides=""left top right bottom""
 *    borderSkin=""mx.skins.halo.HaloBorder""
 *    borderStyle=""inset""
 *    borderThickness=""1""
 *    color=""0x0B333C""
 *    cornerRadius=""0""
 *    disabledColor=""0xAAB3B3""
 *    dropShadowColor=""0x000000""
 *    dropShadowEnabled=""false""
 *    focusAlpha=""0.5""
 *    focusRoundedCorners""tl tr bl br""
 *    fontAntiAliasType=""advanced|normal""
 *    fontFamily=""Verdana""
 *    fontGridFitType=""pixel|none|subpixel""
 *    fontSharpness=""0""
 *    fontSize=""10""
 *    fontStyle=""normal|italic""
 *    fontThickness=""0""
 *    fontWeight=""normal|bold""
 *    paddingLeft=""0""
 *    paddingRight=""0""
 *    shadowDirection=""center""
 *    shadowDistance=""2""
 *    textAlign=""left|right|center""
 *    textDecoration=""none|underline""
 *    textIndent=""0""
 *     
 *    Events
 *    change=""No default""
 *    dataChange=""No default""
 *    enter=""No default""
 *    textInput=""No default""
 *  />
 *  
* * @includeExample examples/TextInputExample.mxml * * @see mx.controls.Label * @see mx.controls.Text * @see mx.controls.TextArea * @see mx.controls.RichTextEditor * @see mx.controls.textClasses.TextRange * * @helpid 3188 * @tiptext TextInput is a single-line, editable text field. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public class TextInput extends UIComponent implements ITextInput { //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * Constructor. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function TextInput() { super(); typeNames = ""TextInput""; COMPILE::SWF { model.addEventListener(""textChange"", textChangeHandler); } } //-------------------------------------------------------------------------- // // Variables // //-------------------------------------------------------------------------- /** * @private * Flag that will block default data/listData behavior. */ private var textSet:Boolean; /** * @private */ private var selectionChanged:Boolean = false; /** * @private */ private var errorCaught:Boolean = false; //-------------------------------------------------------------------------- // // Overridden properties // //-------------------------------------------------------------------------- //---------------------------------- // enabled //---------------------------------- /** * @private */ private var enabledChanged:Boolean = false; private var _disableBead:DisableBead; [Inspectable(category=""General"", enumeration=""true,false"", defaultValue=""true"")] /** * @private * Disable TextField when we're disabled. */ override public function set enabled(value:Boolean):void { if (value == enabled) return; super.enabled = value; // enabledChanged = true; // // invalidateProperties(); // // if (border && border is IInvalidating) // IInvalidating(border).invalidateDisplayList(); if (_disableBead == null) { _disableBead = new DisableBead(); addBead(_disableBead); } _disableBead.disabled = !value; COMPILE::SWF { var textView:TextInputView = view as TextInputView; textView.textField.mouseEnabled = super.enabled; } } //---------------------------------- // tabIndex //---------------------------------- /** * @private * Storage for the tabIndex property. */ private var _tabIndex:int = -1; /** * @private */ private var tabIndexChanged:Boolean = false; /** * @private * Tab order in which the control receives the focus when navigating * with the Tab key. * * @default -1 * @tiptext tabIndex of the component * @helpid 3198 */ // override public function get tabIndex():int // { // return _tabIndex; // } /** * @private */ // override public function set tabIndex(value:int):void // { // if (value == _tabIndex) // return; // // _tabIndex = value; // tabIndexChanged = true; // // invalidateProperties(); // } //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- //---------------------------------- // borderVisible //---------------------------------- public function get borderVisible():Boolean { return true; } public function set borderVisible(value:Boolean) :void { } //---------------------------------- // data //---------------------------------- /** * @private * Storage for the data property. */ private var _data:Object; [Bindable(""dataChange"")] [Inspectable(environment=""none"")] /** * Lets you pass a value to the component * when you use it in an item renderer or item editor. * You typically use data binding to bind a field of the data * property to a property of this component. * *

When you use the control as a drop-in item renderer or drop-in * item editor, Flex automatically writes the current value of the item * to the text property of this control.

* *

You do not set this property in MXML.

* * @default null * @see mx.core.IDataRenderer * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get data():Object { return _data; } /** * @private */ public function set data(value:Object):void { var newText:*; _data = value; if (_listData) { newText = _listData.label; } else if (_data != null) { if (_data is String) newText = String(_data); else newText = _data.toString(); } if (newText !== undefined && !textSet) { text = newText; textSet = false; // changing text should trigger the TextInput's view bead to change the display. //textField.setSelection(0, 0); } dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE)); } //---------------------------------- // displayAsPassword //---------------------------------- /** * @private * Storage for the displayAsPassword property. */ private var _displayAsPassword:Boolean = false; /** * @private */ private var _passwordBead:PasswordInputBead; private var displayAsPasswordChanged:Boolean = false; [Bindable(""displayAsPasswordChanged"")] [Inspectable(category=""General"", defaultValue=""false"")] /** * Indicates whether this control is used for entering passwords. * If true, the field does not display entered text, * instead, each text character entered into the control * appears as the character ""*"". * * @default false * @tiptext Specifies whether to display '*' * instead of the actual characters * @helpid 3197 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get displayAsPassword():Boolean { return _displayAsPassword; } /** * @private */ public function set displayAsPassword(value:Boolean):void { if (value == _displayAsPassword) return; _displayAsPassword = value; // displayAsPasswordChanged = true; // // invalidateProperties(); // invalidateSize(); // invalidateDisplayList();; if (_displayAsPassword && _passwordBead == null) { _passwordBead = new PasswordInputBead(); addBead(_passwordBead); } else if (!_displayAsPassword && _passwordBead != null) { removeBead(_passwordBead); _passwordBead = null; } dispatchEvent(new Event(""displayAsPasswordChanged"")); } //---------------------------------- // editable //---------------------------------- /** * @private * Storage for the editable property. */ private var _editable:Boolean = true; /** * @private */ private var editableChanged:Boolean = false; [Bindable(""editableChanged"")] [Inspectable(category=""General"", defaultValue=""true"")] /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get editable():Boolean { return _editable; } /** * @private */ public function set editable(value:Boolean):void { if (value == _editable) return; _editable = value; editableChanged = true; invalidateProperties(); dispatchEvent(new Event(""editableChanged"")); } //---------------------------------- // horizontalScrollPosition //---------------------------------- /** * @private * Used to store the init time value if any. */ private var _horizontalScrollPosition:Number = 0; /** * @private */ private var horizontalScrollPositionChanged:Boolean = false; [Bindable(""horizontalScrollPositionChanged"")] [Inspectable(defaultValue=""0"")] /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get horizontalScrollPosition():Number { return _horizontalScrollPosition; } /** * @private */ public function set horizontalScrollPosition(value:Number):void { if (value == _horizontalScrollPosition) return; _horizontalScrollPosition = value; horizontalScrollPositionChanged = true; invalidateProperties(); dispatchEvent(new Event(""horizontalScrollPositionChanged"")); } //---------------------------------- // htmlText //---------------------------------- /** * @private * Storage for the htmlText property. * In addition to being set in the htmlText setter, * it is automatically updated at two other times. * 1. When the 'text' or 'htmlText' is pushed down into * the textField in commitProperties(), this causes * the textField to update its own 'htmlText'. * Therefore in commitProperties() we reset this storage var * to be in sync with the textField. * 2. When the TextFormat of the textField changes * because a CSS style has changed (see validateNow() * in UITextField), the textField also updates its own 'htmlText'. * Therefore in textField_textFieldStyleChangeHandler() */ private var _htmlText:String = """"; /** * @private */ private var htmlTextChanged:Boolean = false; /** * @private * The last value of htmlText that was set. * We have to keep track of this because when you set the htmlText * of a TextField and read it back, you don't get what you set. * In general it will have additional HTML markup corresponding * to the defaultTextFormat set from the CSS styles. * If this var is null, it means that 'text' rather than 'htmlText' * was last set. */ private var explicitHTMLText:String = null; [Bindable(""htmlTextChanged"")] [CollapseWhiteSpace] [Inspectable(category=""General"", defaultValue="""")] [NonCommittingChangeEvent(""change"")] /** * Specifies the text displayed by the TextInput control, including HTML markup that * expresses the styles of that text. * When you specify HTML text in this property, you can use the subset of HTML * tags that is supported by the Flash TextField control. * *

When you set this property, the HTML markup is applied * after the CSS styles for the TextInput instance are applied. * When you get this property, the HTML markup includes * the CSS styles.

* *

For example, if you set this to be a string such as, * ""This is an example of <b>bold</b> markup"", * the text ""This is an example of bold markup"" appears * in the TextInput with whatever CSS styles normally apply. * Also, the word ""bold"" appears in boldface font because of the * <b> markup.

* *

HTML markup uses characters such as < and >, * which have special meaning in XML (and therefore in MXML). So, * code such as the following does not compile:

* *
     *  <mx:TextInput htmlText=""This is an example of <b>bold</b> markup""/>
     *  
* *

There are three ways around this problem.

* *
    * *
  • * *

    Set the htmlText property in an ActionScript method called as * an initialize handler:

    * *
         *  <mx:TextInput id=""myTextInput"" initialize=""myTextInput_initialize()""/>
         *  
    * *

    where the myTextInput_initialize method is in a script CDATA section:

    * *
         *  <fx:Script>
         *  <![CDATA[
         *  private function myTextInput_initialize():void {
         *      myTextInput.htmlText = ""This is an example of <b>bold</b> markup"";
         *  }
         *  ]]>
         *  </fx:Script>
         *
         *  
    * *

    This is the simplest approach because the HTML markup * remains easily readable. * Notice that you must assign an id to the TextInput * so you can refer to it in the initialize * handler.

    * *
  • * *
  • * *

    Specify the htmlText property by using a child tag * with a CDATA section. A CDATA section in XML contains character data * where characters like < and > aren't given a special meaning.

    * *
         *  <mx:TextInput>
         *      <mx:htmlText><![CDATA[This is an example of <b>bold</b> markup]]></mx:htmlText>
         *  <mx:TextInput/>
         *  
    * *

    You must write the htmlText property as a child tag * rather than as an attribute on the <mx:TextInput> tag * because XML doesn't allow CDATA for the value of an attribute. * Notice that the markup is readable, but the CDATA section makes * this approach more complicated.

    * *
  • * *
  • * *

    Use an hmtlText attribute where any occurences * of the HTML markup characters < and > in the attribute value * are written instead as the XML ""entities"" &lt; * and &gt;:

    * *
         *  <mx:TextInput htmlText=""This is an example of &lt;b&gt;bold&lt;/b&gt; markup""/&gt;
         *  
    * * Adobe does not recommend this approach because the HTML markup becomes * nearly impossible to read. * *
  • * *
* *

If the condenseWhite property is true * when you set the htmlText property, multiple * white-space characters are condensed, as in HTML-based browsers; * for example, three consecutive spaces are displayed * as a single space. * The default value for condenseWhite is * false, so you must set condenseWhite * to true to collapse the white space.

* *

If you read back the htmlText property quickly * after setting it, you get the same string that you set. * However, after the LayoutManager runs, the value changes * to include additional markup that includes the CSS styles.

* *

Setting the htmlText property affects the text * property in several ways. * If you read the text property quickly after setting * the htmlText property, you get null, * which indicates that the text corresponding to the new * htmlText has not yet been determined. * However, after the LayoutManager runs, the text property * value changes to the htmlText string with all the * HTML markup removed; that is, * the value is the characters that the TextInput actually displays.

* *

Conversely, if you set the text property, * any previously set htmlText is irrelevant. * If you read the htmlText property quickly after setting * the text property, you get null, * which indicates that the htmlText that corresponds to the new * text has not yet been determined. * However, after the LayoutManager runs, the htmlText property * value changes to the new text plus the HTML markup for the CSS styles.

* *

To make the LayoutManager run immediately, you can call the * validateNow() method on the TextInput. * For example, you could set some htmlText, * call the validateNow() method, and immediately * obtain the corresponding text that doesn't have * the HTML markup.

* *

If you set both text and htmlText properties * in ActionScript, whichever is set last takes effect. * Do not set both in MXML, because MXML does not guarantee that * the properties of an instance get set in any particular order.

* *

Setting either text or htmlText property * inside a loop is a fast operation, because the underlying TextField * that actually renders the text is not updated until * the LayoutManager runs.

* *

If you try to set this property to null, * it is set, instead, to the empty string. * If the property temporarily has the value null, * it indicates that the text has been recently set * and the corresponding htmlText * has not yet been determined.

* * @default """" * * @see flash.text.TextField#htmlText * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get htmlText():String { COMPILE::SWF { return ITextModel(model).html; } COMPILE::JS { return (element as HTMLInputElement).value; } } /** * @private */ public function set htmlText(value:String):void { COMPILE::SWF { ITextModel(model).html = value; } COMPILE::JS { (element as HTMLInputElement).value = value; dispatchEvent(new Event('textChange')); } } //---------------------------------- // isHTML //---------------------------------- /** * @private */ private function get isHTML():Boolean { return explicitHTMLText != null; } //---------------------------------- // length //---------------------------------- /** * The number of characters of text displayed in the TextArea. * * @default 0 * @tiptext The number of characters in the TextInput. * @helpid 3192 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get length():int { return text != null ? text.length : -1; } //---------------------------------- // listData //---------------------------------- private var _listData:BaseListData; [Bindable(""dataChange"")] [Inspectable(environment=""none"")] /** * When a component is used as a drop-in item renderer or drop-in * item editor, Flex initializes the listData property * of the component with the appropriate data from the list control. * The component can then use the listData property * to initialize the data property of the drop-in * item renderer or drop-in item editor. * *

You do not set this property in MXML or ActionScript; * Flex sets it when the component is used as a drop-in item renderer * or drop-in item editor.

* * @default null * @see mx.controls.listClasses.IDropInListItemRenderer * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get listData():BaseListData { return _listData; } /** * @private */ public function set listData(value:BaseListData):void { _listData = value; } //---------------------------------- // maxChars //---------------------------------- /** * @private * Storage for the maxChars property. */ private var _maxChars:int = 0; /** * @private */ private var maxCharsChanged:Boolean = false; [Bindable(""maxCharsChanged"")] [Inspectable(category=""General"", defaultValue=""0"")] /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get maxChars():int { return _maxChars; } /** * @private */ public function set maxChars(value:int):void { if (value == _maxChars) return; _maxChars = value; maxCharsChanged = true; invalidateProperties(); dispatchEvent(new Event(""maxCharsChanged"")); } //---------------------------------- // maxHorizontalScrollPosition //---------------------------------- /** * @private * Maximum value of horizontalScrollPosition. * *

The default value is 0, which means that horizontal scrolling is not * required.

* *

The value of the maxHorizontalScrollPosition property is * computed from the data and size of component, and must not be set by * the application code.

*/ public function get maxHorizontalScrollPosition():Number { return 0;//textField ? textField.maxScrollH : 0; } //---------------------------------- // parentDrawsFocus //---------------------------------- /** * @private * Storage for the parentDrawsFocus property. */ private var _parentDrawsFocus:Boolean = false; [Inspectable(category=""General"", enumeration=""true,false"", defaultValue=""false"")] /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get parentDrawsFocus():Boolean { return _parentDrawsFocus; } /** * @private */ public function set parentDrawsFocus(value:Boolean):void { _parentDrawsFocus = value; } //---------------------------------- // restrict //---------------------------------- /** * @private * Storage for the restrict property. */ private var _restrict:String; /** * @private */ private var restrictChanged:Boolean = false; [Bindable(""restrictChanged"")] [Inspectable(category=""General"")] /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get restrict():String { return _restrict; } /** * @private */ public function set restrict(value:String):void { if (value == _restrict) return; _restrict = value; restrictChanged = true; invalidateProperties(); dispatchEvent(new Event(""restrictChanged"")); } //---------------------------------- // selectable //---------------------------------- /** * @private * Used to make TextInput function correctly in the components that use it * as a subcomponent. ComboBox, at this point. */ private var _selectable:Boolean = true; /** * @private */ private var selectableChanged:Boolean = false; /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get selectable():Boolean { return _selectable; } /** * @private */ public function set selectable(value:Boolean):void { if (_selectable == value) return; _selectable = value; selectableChanged = true; invalidateProperties(); } //---------------------------------- // selectionBeginIndex //---------------------------------- /** * @private * Storage for the selectionBeginIndex property. */ private var _selectionBeginIndex:int = 0; [Inspectable(defaultValue=""0"")] /** * The zero-based character index value of the first character * in the current selection. * For example, the first character is 0, the second character is 1, * and so on. * When the control gets the focus, the selection is visible if the * selectionBeginIndex and selectionEndIndex * properties are both set. * * @default 0 * * @tiptext The zero-based index value of the first character * in the selection. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get selectionBeginIndex():int { return _selectionBeginIndex; } /** * @private */ public function set selectionBeginIndex(value:int):void { _selectionBeginIndex = value; } //---------------------------------- // selectionEndIndex //---------------------------------- /** * @private * Storage for the selectionEndIndex property. */ private var _selectionEndIndex:int = 0; [Inspectable(defaultValue=""0"")] /** * The zero-based index of the position after the last character * in the current selection (equivalent to the one-based index of the last * character). * If the last character in the selection, for example, is the fifth * character, this property has the value 5. * When the control gets the focus, the selection is visible if the * selectionBeginIndex and selectionEndIndex * properties are both set. * * @default 0 * * @tiptext The zero-based index value of the last character * in the selection. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get selectionEndIndex():int { return _selectionEndIndex; } /** * @private */ public function set selectionEndIndex(value:int):void { _selectionEndIndex = value; selectionChanged = true; invalidateProperties(); } //---------------------------------- // text //---------------------------------- /** * @private */ private var textChanged:Boolean = false; //[Bindable(""textChanged"")] [Bindable(""change"")] [CollapseWhiteSpace] [Inspectable(category=""General"", defaultValue="""")] //[NonCommittingChangeEvent(""change"")] Not sure what this did // since TextField sends change on every keystroke and other // code looked like it would dispatch a textChanged /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 * @royaleignorecoercion HTMLInputElement */ public function get text():String { COMPILE::SWF { return ITextModel(model).text; } COMPILE::JS { return (element as HTMLInputElement).value; } } /** * @private */ public function set text(value:String):void { COMPILE::SWF { inSetter = true; ITextModel(model).text = value; inSetter = false; } COMPILE::JS { (element as HTMLInputElement).value = value; } dispatchEvent(new Event('textChanged')); dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT)); } //-------------------------------------------------------------------------- // // Overridden methods // //-------------------------------------------------------------------------- /** * @private * Create child objects. */ override protected function createChildren():void { super.createChildren(); } /** * @private */ override protected function commitProperties():void { super.commitProperties(); // if (hasFontContextChanged() && textField != null) // { // var childIndex:int = getChildIndex(DisplayObject(textField)); // removeTextField(); // createTextField(childIndex); // // accessibilityPropertiesChanged = true; // condenseWhiteChanged = true; // displayAsPasswordChanged = true; // enabledChanged = true; // maxCharsChanged = true; // restrictChanged = true; // tabIndexChanged = true; // textChanged = true; // selectionChanged = true; // horizontalScrollPositionChanged = true; // } // // if (accessibilityPropertiesChanged) // { // textField.accessibilityProperties = _accessibilityProperties; // // accessibilityPropertiesChanged = false; // } // // if (condenseWhiteChanged) // { // textField.condenseWhite = _condenseWhite; // // condenseWhiteChanged = false; // } // // if (displayAsPasswordChanged) // { // textField.displayAsPassword = _displayAsPassword; // // displayAsPasswordChanged = false; // } // // if (enabledChanged || editableChanged) // { // textField.type = enabled && _editable ? // TextFieldType.INPUT : // TextFieldType.DYNAMIC; // // if (enabledChanged) // { // if (textField.enabled != enabled) // textField.enabled = enabled; // // enabledChanged = false; // } // selectableChanged = true; // editableChanged = false; // } // // if (selectableChanged) // { // if (_editable) // textField.selectable = enabled; // else // textField.selectable = enabled && _selectable; // selectableChanged = false; // } // // if (maxCharsChanged) // { // textField.maxChars = _maxChars; // // maxCharsChanged = false; // } // // if (restrictChanged) // { // textField.restrict = _restrict; // // restrictChanged = false; // } // // if (tabIndexChanged) // { // textField.tabIndex = _tabIndex; // // tabIndexChanged = false; // } // // if (textChanged || htmlTextChanged) // { // // If the 'text' and 'htmlText' properties have both changed, // // the last one set wins. // if (isHTML) // textField.htmlText = explicitHTMLText; // else // textField.text = _text; // // textFieldChanged(false, true); // // textChanged = false; // htmlTextChanged = false; // } // // if (selectionChanged) // { // textField.setSelection(_selectionBeginIndex, _selectionEndIndex); // // selectionChanged = false; // } // // if (horizontalScrollPositionChanged) // { // textField.scrollH = _horizontalScrollPosition; // // horizontalScrollPositionChanged = false; // } } /** * @private */ override protected function measure():void { super.measure(); trace(""TextInput.measure not implemented""); // var bm:EdgeMetrics = border && border is IRectangularBorder ? // IRectangularBorder(border).borderMetrics : // EdgeMetrics.EMPTY; // // var w:Number; // var h:Number; // // // Start with a width of 160. This may change. // measuredWidth = DEFAULT_MEASURED_WIDTH; // // if (maxChars) // { // // Use the width of ""W"" and multiply by the maxChars // measuredWidth = Math.min(measuredWidth, // measureText(""W"").width * maxChars + bm.left + bm.right + 8); // } // // if (!text || text == """") // { // w = DEFAULT_MEASURED_MIN_WIDTH; // h = measureText("" "").height + // bm.top + bm.bottom + UITextField.TEXT_HEIGHT_PADDING; // h += getStyle(""paddingTop"") + getStyle(""paddingBottom""); // } // else // { // var lineMetrics:TextLineMetrics; // lineMetrics = measureText(text); // // w = lineMetrics.width + bm.left + bm.right + 8; // h = lineMetrics.height + bm.top + bm.bottom + UITextField.TEXT_HEIGHT_PADDING; // // w += getStyle(""paddingLeft"") + getStyle(""paddingRight""); // h += getStyle(""paddingTop"") + getStyle(""paddingBottom""); // } // // measuredWidth = Math.max(w, measuredWidth); // measuredHeight = Math.max(h, DEFAULT_MEASURED_HEIGHT); // // measuredMinWidth = DEFAULT_MEASURED_MIN_WIDTH; // measuredMinHeight = DEFAULT_MEASURED_MIN_HEIGHT; } /** * @private * Stretch the border and fit the TextField inside it. */ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); trace(""TextInput.updateDisplayList not implemented""); // var bm:EdgeMetrics; // // if (border) // { // border.setActualSize(unscaledWidth, unscaledHeight); // bm = border is IRectangularBorder ? // IRectangularBorder(border).borderMetrics : EdgeMetrics.EMPTY; // } // else // { // bm = EdgeMetrics.EMPTY; // } // // var paddingLeft:Number = getStyle(""paddingLeft""); // var paddingRight:Number = getStyle(""paddingRight""); // var paddingTop:Number = getStyle(""paddingTop""); // var paddingBottom:Number = getStyle(""paddingBottom""); // var widthPad:Number = bm.left + bm.right; // var heightPad:Number = bm.top + bm.bottom + 1; // // textField.x = bm.left; // textField.y = bm.top; // // textField.x += paddingLeft; // textField.y += paddingTop; // widthPad += paddingLeft + paddingRight; // heightPad += paddingTop + paddingBottom; // // textField.width = Math.max(0, unscaledWidth - widthPad); // textField.height = Math.max(0, unscaledHeight - heightPad); } /** * @private * Focus should always be on the internal TextField. */ COMPILE::SWF override public function setFocus():void { var textView:TextInputView = view as TextInputView; textView.textField.stage.focus = textView.textField } /** * @private */ override public function styleChanged(styleProp:String):void { trace(""TextInput.styleChanged not implemented""); // var allStyles:Boolean = (styleProp == null || styleProp == ""styleName""); // // super.styleChanged(styleProp); // // // Replace the borderSkin // if (allStyles || styleProp == ""borderSkin"") // { // if (border) // { // removeChild(DisplayObject(border)); // border = null; // createBorder(); // } // } } //-------------------------------------------------------------------------- // // createElement // //-------------------------------------------------------------------------- /** * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement */ COMPILE::JS override protected function createElement():WrappedHTMLElement { addElementToWrapper(this,'input'); element.setAttribute('type', 'text'); //attach input handler to dispatch royale change event when user write in textinput //goog.events.listen(element, 'change', killChangeHandler); goog.events.listen(element, 'input', textChangeHandler); return element; } private var inSetter:Boolean; /** * dispatch change event in response to a textChange event * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion Royale 0.0 */ public function textChangeHandler(event:Event):void { if (!inSetter) dispatchEvent(new Event(Event.CHANGE)); } //-------------------------------------------------------------------------- // // Methods // //-------------------------------------------------------------------------- /** * Creates the border for this component. * Normally the border is determined by the * borderStyle and borderSkin styles. * It must set the border property to the instance * of the border. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function createBorder():void { trace(""TextInput.createBorder not implemented""); // if (!border) // { // var borderClass:Class = getStyle(""borderSkin""); // // if (borderClass != null) // { // border = new borderClass(); // // if (border is ISimpleStyleClient) // ISimpleStyleClient(border).styleName = this; // // // Add the border behind all the children. // addChildAt(DisplayObject(border), 0); // // invalidateDisplayList(); // } // } } /** * Selects the text in the range specified by the parameters. * If the control is not in focus, the selection highlight will not show * until the control gains focus. Also, if the focus is gained by clicking * on the control, any previous selection would be lost. * If the two parameter values are the same, * the new selection is an insertion point. * * @param beginIndex The zero-based index of the first character in the * selection; that is, the first character is 0, the second character * is 1, and so on. * * @param endIndex The zero-based index of the position after * the last character in the selection (equivalent to the one-based * index of the last character). * If the parameter is 5, the last character in the selection, for * example, is the fifth character. * When the TextInput control gets the focus, the selection is visible * if the selectionBeginIndex and selectionEndIndex * properties are both set. * * @tiptext Sets a new text selection. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function setSelection(beginIndex:int, endIndex:int):void { _selectionBeginIndex = beginIndex; _selectionEndIndex = endIndex; selectionChanged = true; invalidateProperties(); } /** * @private * Setting the 'htmlText' of textField changes its 'text', * and vice versa, so afterwards doing so we call this method * to update the storage vars for various properties. * Afterwards, the TextInput's 'text', 'htmlText', 'textWidth', * and 'textHeight' are all in sync with each other * and are identical to the TextField's. */ private function textFieldChanged(styleChangeOnly:Boolean, dispatchValueCommitEvent:Boolean):void { trace(""TextInput.textFieldChanged not implemented""); // var changed1:Boolean; // var changed2:Boolean; // // if (!styleChangeOnly) // { // changed1 = _text != textField.text; // _text = textField.text; // } // // changed2 = _htmlText != textField.htmlText; // _htmlText = textField.htmlText; // // // If the 'text' property changes, trigger bindings to it // // and conditionally dispatch a 'valueCommit' event. // if (changed1) // { // dispatchEvent(new Event(""textChanged"")); // // if (dispatchValueCommitEvent) // dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT)); // } // // If the 'htmlText' property changes, trigger bindings to it. // if (changed2) // dispatchEvent(new Event(""htmlTextChanged"")); // // _textWidth = textField.textWidth; // _textHeight = textField.textHeight; } //-------------------------------------------------------------------------- // // ITextInput Interface // //-------------------------------------------------------------------------- /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get selectionActivePosition():int { return selectionEndIndex; } /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get selectionAnchorPosition():int { return selectionBeginIndex; } /** * Selects the text in the range specified by the parameters. Unlike * setSelection this is done immediately. * * @param anchorIndex The zero-based character index specifying the beginning * of the selection that stays fixed when the selection is extended. * * @param activeIndex The zero-based character index specifying * the end of the selection that moves when the selection is extended. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function selectRange(anchorIndex:int, activeIndex:int):void { trace(""TextInput.selectRange not implemented""); // Do it immediately. // textField.setSelection(anchorIndex, activeIndex); } //-------------------------------------------------------------------------- // // Overridden event handlers: UIComponent // //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // // Event handlers // //-------------------------------------------------------------------------- } } ",12476,True,2590.35944614014,median "/* FlipMode.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* Preconditions: Uno with DOGS102 Shield */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1306_72X40_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_WS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_RAYSTAR_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_RAYSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_KS0713_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_KS0713_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7567_HEM6432_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_IST7920_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_IST7920_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_DEM240064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1617_JLX128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1617_JLX128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list void setup(void) { u8g2.begin(); u8g2.setFont(u8g2_font_6x10_tr); } void draw(const char *s) { u8g2.firstPage(); do { u8g2.drawStr(2,15,""Hello World!""); u8g2.drawStr(2,30,s); u8g2.drawFrame(0,0,u8g2.getDisplayWidth(),u8g2.getDisplayHeight() ); u8g2.drawStr(2, 45, u8x8_u16toa(u8g2.getDisplayWidth(), 5)); u8g2.drawStr(2, 60, u8x8_u16toa(u8g2.getDisplayHeight(), 5)); } while ( u8g2.nextPage() ); delay(2000); } void loop(void) { u8g2.clearDisplay(); u8g2.setDisplayRotation(U8G2_R0); u8g2.setFlipMode(0); draw(""R0,F0""); u8g2.clearDisplay(); u8g2.setFlipMode(1); draw(""R0,F1""); u8g2.clearDisplay(); u8g2.setDisplayRotation(U8G2_R1); u8g2.setFlipMode(0); draw(""R1,F0""); u8g2.clearDisplay(); u8g2.setFlipMode(1); draw(""R1,F1""); u8g2.clearDisplay(); u8g2.setDisplayRotation(U8G2_R2); u8g2.setFlipMode(0); draw(""R2,F0""); u8g2.clearDisplay(); u8g2.setFlipMode(1); draw(""R2,F1""); u8g2.clearDisplay(); u8g2.setDisplayRotation(U8G2_R3); u8g2.setFlipMode(0); draw(""R3,F0""); u8g2.clearDisplay(); u8g2.setFlipMode(1); draw(""R3,F1""); } ",16247,True,4861.355001852905,median "/* Feathers Copyright 2012-2013 Joshua Tynjala. All Rights Reserved. This program is free software. You can redistribute and/or modify it in accordance with the terms of the accompanying license agreement. */ package feathers.controls { import feathers.controls.renderers.DefaultGroupedListHeaderOrFooterRenderer; import feathers.controls.renderers.DefaultGroupedListItemRenderer; import feathers.controls.supportClasses.GroupedListDataViewPort; import feathers.core.IFocusDisplayObject; import feathers.core.PropertyProxy; import feathers.data.HierarchicalCollection; import feathers.events.CollectionEventType; import feathers.events.FeathersEventType; import feathers.layout.ILayout; import feathers.layout.VerticalLayout; import flash.geom.Point; import flash.ui.Keyboard; import starling.events.Event; import starling.events.KeyboardEvent; /** * Dispatched when the selected item changes. * * @eventType starling.events.Event.CHANGE */ [Event(name=""change"",type=""starling.events.Event"")] /** * Dispatched when an item renderer is added to the list. When the layout is * virtualized, item renderers may not exist for every item in the data * provider. This event can be used to track which items currently have * renderers. * * @eventType feathers.events.FeathersEventType.RENDERER_ADD */ [Event(name=""rendererAdd"",type=""starling.events.Event"")] /** * Dispatched when an item renderer is removed from the list. When the layout is * virtualized, item renderers may not exist for every item in the data * provider. This event can be used to track which items currently have * renderers. * * @eventType feathers.events.FeathersEventType.RENDERER_REMOVE */ [Event(name=""rendererRemove"",type=""starling.events.Event"")] [DefaultProperty(""dataProvider"")] /** * Displays a list of items divided into groups or sections. Takes a * hierarchical provider limited to two levels of hierarchy. This component * supports scrolling, custom item (and header and footer) renderers, and * custom layouts. * *

Layouts may be, and are highly encouraged to be, virtual, * meaning that the List is capable of creating a limited number of item * renderers to display a subset of the data provider instead of creating a * renderer for every single item. This allows for optimal performance with * very large data providers.

* * @see http://wiki.starling-framework.org/feathers/grouped-list */ public class GroupedList extends Scroller implements IFocusDisplayObject { /** * @private */ private static const HELPER_POINT:Point = new Point(); /** * An alternate name to use with GroupedList to allow a theme to give it * an inset style. If a theme does not provide a skin for the inset * grouped list, the theme will automatically fall back to using the * default grouped list skin. * * @see feathers.core.IFeathersControl#nameList */ public static const ALTERNATE_NAME_INSET_GROUPED_LIST:String = ""feathers-inset-grouped-list""; /** * The default name to use with header renderers. * * @see feathers.core.IFeathersControl#nameList */ public static const DEFAULT_CHILD_NAME_HEADER_RENDERER:String = ""feathers-grouped-list-header-renderer""; /** * An alternate name to use with header renderers to give them an inset * style. * * @see feathers.core.IFeathersControl#nameList */ public static const ALTERNATE_CHILD_NAME_INSET_HEADER_RENDERER:String = ""feathers-grouped-list-inset-header-renderer""; /** * The default name to use with footer renderers. * * @see feathers.core.IFeathersControl#nameList */ public static const DEFAULT_CHILD_NAME_FOOTER_RENDERER:String = ""feathers-grouped-list-footer-renderer""; /** * An alternate name to use with footer renderers to give them an inset * style. */ public static const ALTERNATE_CHILD_NAME_INSET_FOOTER_RENDERER:String = ""feathers-grouped-list-inset-footer-renderer""; /** * An alternate name to use with item renderers to give them an inset * style. * * @see feathers.core.IFeathersControl#nameList */ public static const ALTERNATE_CHILD_NAME_INSET_ITEM_RENDERER:String = ""feathers-grouped-list-inset-item-renderer""; /** * An alternate name to use for item renderers to give them an inset * style. Typically meant to be used for the renderer of the first item * in a group. * * @see feathers.core.IFeathersControl#nameList */ public static const ALTERNATE_CHILD_NAME_INSET_FIRST_ITEM_RENDERER:String = ""feathers-grouped-list-inset-first-item-renderer""; /** * An alternate name to use for item renderers to give them an inset * style. Typically meant to be used for the renderer of the last item * in a group. * * @see feathers.core.IFeathersControl#nameList */ public static const ALTERNATE_CHILD_NAME_INSET_LAST_ITEM_RENDERER:String = ""feathers-grouped-list-inset-last-item-renderer""; /** * An alternate name to use for item renderers to give them an inset * style. Typically meant to be used for the renderer of an item in a * group that has no other items. * * @see feathers.core.IFeathersControl#nameList */ public static const ALTERNATE_CHILD_NAME_INSET_SINGLE_ITEM_RENDERER:String = ""feathers-grouped-list-inset-single-item-renderer""; /** * @copy feathers.controls.Scroller#SCROLL_POLICY_AUTO */ public static const SCROLL_POLICY_AUTO:String = ""auto""; /** * @copy feathers.controls.Scroller#SCROLL_POLICY_ON */ public static const SCROLL_POLICY_ON:String = ""on""; /** * @copy feathers.controls.Scroller#SCROLL_POLICY_OFF */ public static const SCROLL_POLICY_OFF:String = ""off""; /** * @copy feathers.controls.Scroller#SCROLL_BAR_DISPLAY_MODE_FLOAT */ public static const SCROLL_BAR_DISPLAY_MODE_FLOAT:String = ""float""; /** * @copy feathers.controls.Scroller#SCROLL_BAR_DISPLAY_MODE_FIXED */ public static const SCROLL_BAR_DISPLAY_MODE_FIXED:String = ""fixed""; /** * @copy feathers.controls.Scroller#SCROLL_BAR_DISPLAY_MODE_NONE */ public static const SCROLL_BAR_DISPLAY_MODE_NONE:String = ""none""; /** * @copy feathers.controls.Scroller#INTERACTION_MODE_TOUCH */ public static const INTERACTION_MODE_TOUCH:String = ""touch""; /** * @copy feathers.controls.Scroller#INTERACTION_MODE_MOUSE */ public static const INTERACTION_MODE_MOUSE:String = ""mouse""; /** * Constructor. */ public function GroupedList() { super(); this.addEventListener(FeathersEventType.FOCUS_IN, list_focusInHandler); this.addEventListener(FeathersEventType.FOCUS_OUT, list_focusOutHandler); } /** * @private * The guts of the List's functionality. Handles layout and selection. */ protected var dataViewPort:GroupedListDataViewPort; /** * @private */ protected var _layout:ILayout; /** * The layout algorithm used to position and, optionally, size the * list's items. */ public function get layout():ILayout { return this._layout; } /** * @private */ public function set layout(value:ILayout):void { if(this._layout == value) { return; } this._layout = value; this.invalidate(INVALIDATION_FLAG_SCROLL); } /** * @private */ protected var _dataProvider:HierarchicalCollection; /** * The collection of data displayed by the list. */ public function get dataProvider():HierarchicalCollection { return this._dataProvider; } /** * @private */ public function set dataProvider(value:HierarchicalCollection):void { if(this._dataProvider == value) { return; } if(this._dataProvider) { this._dataProvider.removeEventListener(CollectionEventType.RESET, dataProvider_resetHandler); } this._dataProvider = value; if(this._dataProvider) { this._dataProvider.addEventListener(CollectionEventType.RESET, dataProvider_resetHandler); } //reset the scroll position because this is a drastic change and //the data is probably completely different this.horizontalScrollPosition = 0; this.verticalScrollPosition = 0; this.invalidate(INVALIDATION_FLAG_DATA); } /** * @private */ protected var _isSelectable:Boolean = true; /** * Determines if an item in the list may be selected. */ public function get isSelectable():Boolean { return this._isSelectable; } /** * @private */ public function set isSelectable(value:Boolean):void { if(this._isSelectable == value) { return; } this._isSelectable = value; if(!this._isSelectable) { this.setSelectedLocation(-1, -1); } this.invalidate(INVALIDATION_FLAG_SELECTED); } /** * @private */ protected var _selectedGroupIndex:int = -1; /** * The group index of the currently selected item. Returns -1 if no item * is selected. * * @see #selectedItemIndex */ public function get selectedGroupIndex():int { return this._selectedGroupIndex; } /** * @private */ protected var _selectedItemIndex:int = -1; /** * The item index of the currently selected item. Returns -1 if no item * is selected. * * @see #selectedGroupIndex */ public function get selectedItemIndex():int { return this._selectedItemIndex; } /** * The currently selected item. Returns null if no item is selected. */ public function get selectedItem():Object { if(!this._dataProvider || this._selectedGroupIndex < 0 || this._selectedItemIndex < 0) { return null; } return this._dataProvider.getItemAt(this._selectedGroupIndex, this._selectedItemIndex); } /** * @private */ public function set selectedItem(value:Object):void { const result:Vector. = this._dataProvider.getItemLocation(value); if(result.length == 2) { this.setSelectedLocation(result[0], result[1]); } else { this.setSelectedLocation(-1, -1); } } /** * @private */ protected var _itemRendererType:Class = DefaultGroupedListItemRenderer; /** * The class used to instantiate item renderers. * * @see feathers.controls.renderer.IGroupedListItemRenderer * @see #itemRendererFactory * @see #firstItemRendererType * @see #firstItemRendererFactory * @see #lastItemRendererType * @see #lastItemRendererFactory * @see #singleItemRendererType * @see #singleItemRendererFactory */ public function get itemRendererType():Class { return this._itemRendererType; } /** * @private */ public function set itemRendererType(value:Class):void { if(this._itemRendererType == value) { return; } this._itemRendererType = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _itemRendererFactory:Function; /** * A function called that is expected to return a new item renderer. Has * a higher priority than itemRendererType. Typically, you * would use an itemRendererFactory instead of an * itemRendererType if you wanted to initialize some * properties on each separate item renderer, such as skins. * *

The function is expected to have the following signature:

* *
function():IGroupedListItemRenderer
* * @see feathers.controls.renderers.IGroupedListItemRenderer * @see #itemRendererType * @see #firstItemRendererType * @see #firstItemRendererFactory * @see #lastItemRendererType * @see #lastItemRendererFactory * @see #singleItemRendererType * @see #singleItemRendererFactory */ public function get itemRendererFactory():Function { return this._itemRendererFactory; } /** * @private */ public function set itemRendererFactory(value:Function):void { if(this._itemRendererFactory === value) { return; } this._itemRendererFactory = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _typicalItem:Object = null; /** * An item used to create a sample item renderer used for virtual layout * measurement. */ public function get typicalItem():Object { return this._typicalItem; } /** * @private */ public function set typicalItem(value:Object):void { if(this._typicalItem == value) { return; } this._typicalItem = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _itemRendererName:String; /** * A name to add to all item renderers in this list. Typically used by a * theme to provide different skins to different lists. * * @see feathers.core.FeathersControl#nameList * @see #firstItemRendererName * @see #lastItemRendererName * @see #singleItemRendererName */ public function get itemRendererName():String { return this._itemRendererName; } /** * @private */ public function set itemRendererName(value:String):void { if(this._itemRendererName == value) { return; } this._itemRendererName = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _itemRendererProperties:PropertyProxy; /** * A set of key/value pairs to be passed down to all of the list's item * renderers. These values are shared by each item renderer, so values * that cannot be shared (such as display objects that need to be added * to the display list) should be passed to the item renderers using an * itemRendererFactory or with a theme. * *

If the subcomponent has its own subcomponents, their properties * can be set too, using attribute @ notation. For example, * to set the skin on the thumb of a SimpleScrollBar * which is in a Scroller which is in a List, * you can use the following syntax:

*
list.scrollerProperties.@verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);
* * @see feathers.controls.renderers.IGroupedListItemRenderer * @see #itemRendererFactory */ public function get itemRendererProperties():Object { if(!this._itemRendererProperties) { this._itemRendererProperties = new PropertyProxy(childProperties_onChange); } return this._itemRendererProperties; } /** * @private */ public function set itemRendererProperties(value:Object):void { if(this._itemRendererProperties == value) { return; } if(!value) { value = new PropertyProxy(); } if(!(value is PropertyProxy)) { const newValue:PropertyProxy = new PropertyProxy(); for(var propertyName:String in value) { newValue[propertyName] = value[propertyName]; } value = newValue; } if(this._itemRendererProperties) { this._itemRendererProperties.removeOnChangeCallback(childProperties_onChange); } this._itemRendererProperties = PropertyProxy(value); if(this._itemRendererProperties) { this._itemRendererProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _firstItemRendererType:Class; /** * The class used to instantiate the item renderer for the first item in * a group. * * @see feathers.controls.renderer.IGroupedListItemRenderer * @see #firstItemRendererFactory * @see #itemRendererType * @see #itemRendererFactory * @see #lastItemRendererType * @see #lastItemRendererFactory * @see #singleItemRendererType * @see #singleItemRendererFactory */ public function get firstItemRendererType():Class { return this._firstItemRendererType; } /** * @private */ public function set firstItemRendererType(value:Class):void { if(this._firstItemRendererType == value) { return; } this._firstItemRendererType = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _firstItemRendererFactory:Function; /** * A function called that is expected to return a new item renderer for * the first item in a group. Has a higher priority than * firstItemRendererType. Typically, you would use an * firstItemRendererFactory instead of an * firstItemRendererType if you wanted to initialize some * properties on each separate item renderer, such as skins. * *

The function is expected to have the following signature:

* *
function():IGroupedListItemRenderer
* * @see feathers.controls.renderers.IGroupedListItemRenderer * @see #firstItemRendererType * @see #itemRendererType * @see #itemRendererFactory * @see #lastItemRendererType * @see #lastItemRendererFactory * @see #singleItemRendererType * @see #singleItemRendererFactory */ public function get firstItemRendererFactory():Function { return this._firstItemRendererFactory; } /** * @private */ public function set firstItemRendererFactory(value:Function):void { if(this._firstItemRendererFactory === value) { return; } this._firstItemRendererFactory = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _firstItemRendererName:String; /** * A name to add to all item renderers in this list that are the first * item in a group. Typically used by a theme to provide different skins * to different lists, and to differentiate first items from regular * items if they are created with the same class. If this value is null * the regular itemRendererName will be used instead. * * @see feathers.core.FeathersControl#nameList * @see #itemRendererName * @see #lastItemRendererName * @see #singleItemRendererName */ public function get firstItemRendererName():String { return this._firstItemRendererName; } /** * @private */ public function set firstItemRendererName(value:String):void { if(this._firstItemRendererName == value) { return; } this._firstItemRendererName = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _lastItemRendererType:Class; /** * The class used to instantiate the item renderer for the last item in * a group. * * @see feathers.controls.renderer.IGroupedListItemRenderer * @see #lastItemRendererFactory * @see #itemRendererType * @see #itemRendererFactory * @see #firstItemRendererType * @see #firstItemRendererFactory * @see #singleItemRendererType * @see #singleItemRendererFactory */ public function get lastItemRendererType():Class { return this._lastItemRendererType; } /** * @private */ public function set lastItemRendererType(value:Class):void { if(this._lastItemRendererType == value) { return; } this._lastItemRendererType = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _lastItemRendererFactory:Function; /** * A function called that is expected to return a new item renderer for * the last item in a group. Has a higher priority than * lastItemRendererType. Typically, you would use an * lastItemRendererFactory instead of an * lastItemRendererType if you wanted to initialize some * properties on each separate item renderer, such as skins. * *

The function is expected to have the following signature:

* *
function():IGroupedListItemRenderer
* * @see feathers.controls.renderers.IGroupedListItemRenderer * @see #lastItemRendererType * @see #itemRendererType * @see #itemRendererFactory * @see #firstItemRendererType * @see #firstItemRendererFactory * @see #singleItemRendererType * @see #singleItemRendererFactory */ public function get lastItemRendererFactory():Function { return this._lastItemRendererFactory; } /** * @private */ public function set lastItemRendererFactory(value:Function):void { if(this._lastItemRendererFactory === value) { return; } this._lastItemRendererFactory = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _lastItemRendererName:String; /** * A name to add to all item renderers in this list that are the last * item in a group. Typically used by a theme to provide different skins * to different lists, and to differentiate last items from regular * items if they are created with the same class. If this value is null * the regular itemRendererName will be used instead. * * @see feathers.core.FeathersControl#nameList * @see #itemRendererName * @see #firstItemRendererName * @see #singleItemRendererName */ public function get lastItemRendererName():String { return this._lastItemRendererName; } /** * @private */ public function set lastItemRendererName(value:String):void { if(this._lastItemRendererName == value) { return; } this._lastItemRendererName = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _singleItemRendererType:Class; /** * The class used to instantiate the item renderer for an item in a * group with no other items. * * @see feathers.controls.renderer.IGroupedListItemRenderer * @see #singleItemRendererFactory * @see #itemRendererType * @see #itemRendererFactory * @see #firstItemRendererType * @see #firstItemRendererFactory * @see #lastItemRendererType * @see #lastItemRendererFactory */ public function get singleItemRendererType():Class { return this._singleItemRendererType; } /** * @private */ public function set singleItemRendererType(value:Class):void { if(this._singleItemRendererType == value) { return; } this._singleItemRendererType = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _singleItemRendererFactory:Function; /** * A function called that is expected to return a new item renderer for * an item in a group with no other items. Has a higher priority than * singleItemRendererType. Typically, you would use an * singleItemRendererFactory instead of an * singleItemRendererType if you wanted to initialize some * properties on each separate item renderer, such as skins. * *

The function is expected to have the following signature:

* *
function():IGroupedListItemRenderer
* * @see feathers.controls.renderers.IGroupedListItemRenderer * @see #singleItemRendererType * @see #itemRendererType * @see #itemRendererFactory * @see #firstItemRendererType * @see #firstItemRendererFactory * @see #lastItemRendererType * @see #lastItemRendererFactory */ public function get singleItemRendererFactory():Function { return this._singleItemRendererFactory; } /** * @private */ public function set singleItemRendererFactory(value:Function):void { if(this._singleItemRendererFactory === value) { return; } this._singleItemRendererFactory = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _singleItemRendererName:String; /** * A name to add to all item renderers in this list that are an item in * a group with no other items. Typically used by a theme to provide * different skins to different lists, and to differentiate single items * from other items if they are created with the same class. If this * value is null the regular itemRendererName will be used * instead. * * @see feathers.core.FeathersControl#nameList * @see #itemRendererName * @see #firstItemRendererName * @see #lastItemRendererName */ public function get singleItemRendererName():String { return this._singleItemRendererName; } /** * @private */ public function set singleItemRendererName(value:String):void { if(this._singleItemRendererName == value) { return; } this._singleItemRendererName = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _headerRendererType:Class = DefaultGroupedListHeaderOrFooterRenderer; /** * The class used to instantiate header renderers. * * @see feathers.controls.renderers.IGroupedListHeaderOrFooterRenderer * @see #headerRendererFactory */ public function get headerRendererType():Class { return this._headerRendererType; } /** * @private */ public function set headerRendererType(value:Class):void { if(this._headerRendererType == value) { return; } this._headerRendererType = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _headerRendererFactory:Function; /** * A function called that is expected to return a new header renderer. * Has a higher priority than headerRendererType. * Typically, you would use an headerRendererFactory * instead of a headerRendererType if you wanted to * initialize some properties on each separate header renderer, such as * skins. * *

The function is expected to have the following signature:

* *
function():IGroupedListHeaderOrFooterRenderer
* * @see feathers.controls.renderers.IGroupedListHeaderOrFooterRenderer * @see #headerRendererType */ public function get headerRendererFactory():Function { return this._headerRendererFactory; } /** * @private */ public function set headerRendererFactory(value:Function):void { if(this._headerRendererFactory === value) { return; } this._headerRendererFactory = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _typicalHeader:Object = null; /** * Used to auto-size the grouped list. If the list's width or height is * NaN, the grouped list will try to automatically pick an ideal size. * This data is used in that process to create a sample header renderer. */ public function get typicalHeader():Object { return this._typicalHeader; } /** * @private */ public function set typicalHeader(value:Object):void { if(this._typicalHeader == value) { return; } this._typicalHeader = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _headerRendererName:String = DEFAULT_CHILD_NAME_HEADER_RENDERER; /** * A name to add to all header renderers in this grouped list. Typically * used by a theme to provide different skins to different lists. * * @see feathers.core.FeathersControl#nameList */ public function get headerRendererName():String { return this._headerRendererName; } /** * @private */ public function set headerRendererName(value:String):void { if(this._headerRendererName == value) { return; } this._headerRendererName = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _headerRendererProperties:PropertyProxy; /** * A set of key/value pairs to be passed down to all of the grouped * list's header renderers. These values are shared by each header * renderer, so values that cannot be shared (such as display objects * that need to be added to the display list) should be passed to the * header renderers using a headerRendererFactory or with a * theme. * *

If the subcomponent has its own subcomponents, their properties * can be set too, using attribute @ notation. For example, * to set the skin on the thumb of a SimpleScrollBar * which is in a Scroller which is in a List, * you can use the following syntax:

*
list.scrollerProperties.@verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);
* * @see #headerRendererFactory */ public function get headerRendererProperties():Object { if(!this._headerRendererProperties) { this._headerRendererProperties = new PropertyProxy(childProperties_onChange); } return this._headerRendererProperties; } /** * @private */ public function set headerRendererProperties(value:Object):void { if(this._headerRendererProperties == value) { return; } if(!value) { value = new PropertyProxy(); } if(!(value is PropertyProxy)) { const newValue:PropertyProxy = new PropertyProxy(); for(var propertyName:String in value) { newValue[propertyName] = value[propertyName]; } value = newValue; } if(this._headerRendererProperties) { this._headerRendererProperties.removeOnChangeCallback(childProperties_onChange); } this._headerRendererProperties = PropertyProxy(value); if(this._headerRendererProperties) { this._headerRendererProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _footerRendererType:Class = DefaultGroupedListHeaderOrFooterRenderer; /** * The class used to instantiate footer renderers. * * @see feathers.controls.renderers.IGroupedListHeaderOrFooterRenderer * @see #footerRendererFactory */ public function get footerRendererType():Class { return this._footerRendererType; } /** * @private */ public function set footerRendererType(value:Class):void { if(this._footerRendererType == value) { return; } this._footerRendererType = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _footerRendererFactory:Function; /** * A function called that is expected to return a new footer renderer. * Has a higher priority than footerRendererType. * Typically, you would use an footerRendererFactory * instead of a footerRendererType if you wanted to * initialize some properties on each separate footer renderer, such as * skins. * *

The function is expected to have the following signature:

* *
function():IGroupedListHeaderOrFooterRenderer
* * @see feathers.controls.renderers.IGroupedListHeaderOrFooterRenderer * @see #footerRendererType */ public function get footerRendererFactory():Function { return this._footerRendererFactory; } /** * @private */ public function set footerRendererFactory(value:Function):void { if(this._footerRendererFactory === value) { return; } this._footerRendererFactory = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _typicalFooter:Object = null; /** * Used to auto-size the grouped list. If the grouped list's width or * height is NaN, the grouped list will try to automatically pick an * ideal size. This data is used in that process to create a sample * footer renderer. */ public function get typicalFooter():Object { return this._typicalFooter; } /** * @private */ public function set typicalFooter(value:Object):void { if(this._typicalFooter == value) { return; } this._typicalFooter = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _footerRendererName:String = DEFAULT_CHILD_NAME_FOOTER_RENDERER; /** * A name to add to all footer renderers in this grouped list. Typically * used by a theme to provide different skins to different lists. * * @see feathers.core.FeathersControl#nameList */ public function get footerRendererName():String { return this._footerRendererName; } /** * @private */ public function set footerRendererName(value:String):void { if(this._footerRendererName == value) { return; } this._footerRendererName = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _footerRendererProperties:PropertyProxy; /** * A set of key/value pairs to be passed down to all of the grouped * list's footer renderers. These values are shared by each footer * renderer, so values that cannot be shared (such as display objects * that need to be added to the display list) should be passed to the * footer renderers using a footerRendererFactory or with * a theme. * *

If the subcomponent has its own subcomponents, their properties * can be set too, using attribute @ notation. For example, * to set the skin on the thumb of a SimpleScrollBar * which is in a Scroller which is in a List, * you can use the following syntax:

*
list.scrollerProperties.@verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);
* * @see #itemRendererFactory */ public function get footerRendererProperties():Object { if(!this._footerRendererProperties) { this._footerRendererProperties = new PropertyProxy(childProperties_onChange); } return this._footerRendererProperties; } /** * @private */ public function set footerRendererProperties(value:Object):void { if(this._footerRendererProperties == value) { return; } if(!value) { value = new PropertyProxy(); } if(!(value is PropertyProxy)) { const newValue:PropertyProxy = new PropertyProxy(); for(var propertyName:String in value) { newValue[propertyName] = value[propertyName]; } value = newValue; } if(this._footerRendererProperties) { this._footerRendererProperties.removeOnChangeCallback(childProperties_onChange); } this._footerRendererProperties = PropertyProxy(value); if(this._footerRendererProperties) { this._footerRendererProperties.addOnChangeCallback(childProperties_onChange); } this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _headerField:String = ""header""; /** * The field in a group that contains the data for a header. If the * group does not have this field, and a headerFunction is * not defined, then no header will be displayed for the group. In other * words, a header is optional, and a group may not have one. * *

All of the header fields and functions, ordered by priority:

*
    *
  1. headerFunction
  2. *
  3. headerField
  4. *
* * @see #headerFunction */ public function get headerField():String { return this._headerField; } /** * @private */ public function set headerField(value:String):void { if(this._headerField == value) { return; } this._headerField = value; this.invalidate(INVALIDATION_FLAG_DATA); } /** * @private */ protected var _headerFunction:Function; /** * A function used to generate header data for a specific group. If this * function is not null, then the headerField will be * ignored. * *

All of the header fields and functions, ordered by priority:

*
    *
  1. headerFunction
  2. *
  3. headerField
  4. *
* * @see #headerField */ public function get headerFunction():Function { return this._headerFunction; } /** * @private */ public function set headerFunction(value:Function):void { if(this._headerFunction == value) { return; } this._headerFunction = value; this.invalidate(INVALIDATION_FLAG_DATA); } /** * @private */ protected var _footerField:String = ""footer""; /** * The field in a group that contains the data for a footer. If the * group does not have this field, and a footerFunction is * not defined, then no footer will be displayed for the group. In other * words, a footer is optional, and a group may not have one. * *

All of the footer fields and functions, ordered by priority:

*
    *
  1. footerFunction
  2. *
  3. footerField
  4. *
* * @see #footerFunction */ public function get footerField():String { return this._footerField; } /** * @private */ public function set footerField(value:String):void { if(this._footerField == value) { return; } this._footerField = value; this.invalidate(INVALIDATION_FLAG_DATA); } /** * @private */ protected var _footerFunction:Function; /** * A function used to generate footer data for a specific group. If this * function is not null, then the footerField will be * ignored. * *

All of the footer fields and functions, ordered by priority:

*
    *
  1. footerFunction
  2. *
  3. footerField
  4. *
* * @see #footerField */ public function get footerFunction():Function { return this._footerFunction; } /** * @private */ public function set footerFunction(value:Function):void { if(this._footerFunction == value) { return; } this._footerFunction = value; this.invalidate(INVALIDATION_FLAG_DATA); } /** * The pending group index to scroll to after validating. A value of * -1 means that the scroller won't scroll to a group after * validating. */ protected var pendingGroupIndex:int = -1; /** * The pending item index to scroll to after validating. A value of * -1 means that the scroller won't scroll to an item after * validating. */ protected var pendingItemIndex:int = -1; /** * @private */ override public function scrollToPosition(horizontalScrollPosition:Number, verticalScrollPosition:Number, animationDuration:Number = 0):void { this.pendingItemIndex = -1; super.scrollToPosition(horizontalScrollPosition, verticalScrollPosition, animationDuration); } /** * @private */ override public function scrollToPageIndex(horizontalPageIndex:int, verticalPageIndex:int, animationDuration:Number = 0):void { this.pendingGroupIndex = -1; this.pendingItemIndex = -1; super.scrollToPageIndex(horizontalPageIndex, verticalPageIndex, animationDuration); } /** * After the next validation, scrolls the list so that the specified * item is visible. If animationDuration is greater than * zero, the scroll will animate. The duration is in seconds. */ public function scrollToDisplayIndex(groupIndex:int, itemIndex:int, animationDuration:Number = 0):void { this.pendingHorizontalPageIndex = -1; this.pendingVerticalPageIndex = -1; this.pendingHorizontalScrollPosition = NaN; this.pendingVerticalScrollPosition = NaN; if(this.pendingGroupIndex == groupIndex && this.pendingItemIndex == itemIndex && this.pendingScrollDuration == animationDuration) { return; } this.pendingGroupIndex = groupIndex; this.pendingItemIndex = itemIndex; this.pendingScrollDuration = animationDuration; this.invalidate(INVALIDATION_FLAG_PENDING_SCROLL); } /** * Sets the selected group and item index. */ public function setSelectedLocation(groupIndex:int, itemIndex:int):void { if(this._selectedGroupIndex == groupIndex && this._selectedItemIndex == itemIndex) { return; } if((groupIndex < 0 && itemIndex >= 0) || (groupIndex >= 0 && itemIndex < 0)) { throw new ArgumentError(""To deselect items, group index and item index must both be < 0.""); } this._selectedGroupIndex = groupIndex; this._selectedItemIndex = itemIndex; this.invalidate(INVALIDATION_FLAG_SELECTED); this.dispatchEventWith(Event.CHANGE); } /** * Extracts header data from a group object. */ public function groupToHeaderData(group:Object):Object { if(this._headerFunction != null) { return this._headerFunction(group); } else if(this._headerField != null && group && group.hasOwnProperty(this._headerField)) { return group[this._headerField]; } return null; } /** * Extracts footer data from a group object. */ public function groupToFooterData(group:Object):Object { if(this._footerFunction != null) { return this._footerFunction(group); } else if(this._footerField != null && group && group.hasOwnProperty(this._footerField)) { return group[this._footerField]; } return null; } /** * @private */ override protected function initialize():void { const hasLayout:Boolean = this._layout != null; super.initialize(); if(!this.dataViewPort) { this.viewPort = this.dataViewPort = new GroupedListDataViewPort(); this.dataViewPort.owner = this; this.dataViewPort.addEventListener(Event.CHANGE, dataViewPort_changeHandler); this.viewPort = this.dataViewPort; } if(!hasLayout) { if(this._hasElasticEdges && this._verticalScrollPolicy == SCROLL_POLICY_AUTO && this._scrollBarDisplayMode != SCROLL_BAR_DISPLAY_MODE_FIXED) { //so that the elastic edges work even when the max scroll //position is 0, similar to iOS. this.verticalScrollPolicy = SCROLL_POLICY_ON; } const layout:VerticalLayout = new VerticalLayout(); layout.useVirtualLayout = true; layout.paddingTop = layout.paddingRight = layout.paddingBottom = layout.paddingLeft = 0; layout.gap = 0; layout.horizontalAlign = VerticalLayout.HORIZONTAL_ALIGN_JUSTIFY; layout.verticalAlign = VerticalLayout.VERTICAL_ALIGN_TOP; this._layout = layout; } } /** * @private */ override protected function draw():void { this.refreshDataViewPortProperties(); super.draw(); } /** * @private */ protected function refreshDataViewPortProperties():void { this.dataViewPort.isSelectable = this._isSelectable; this.dataViewPort.setSelectedLocation(this._selectedGroupIndex, this._selectedItemIndex); this.dataViewPort.dataProvider = this._dataProvider; this.dataViewPort.itemRendererType = this._itemRendererType; this.dataViewPort.itemRendererFactory = this._itemRendererFactory; this.dataViewPort.itemRendererProperties = this._itemRendererProperties; this.dataViewPort.itemRendererName = this._itemRendererName; this.dataViewPort.typicalItem = this._typicalItem; this.dataViewPort.firstItemRendererType = this._firstItemRendererType; this.dataViewPort.firstItemRendererFactory = this._firstItemRendererFactory; this.dataViewPort.firstItemRendererName = this._firstItemRendererName; this.dataViewPort.lastItemRendererType = this._lastItemRendererType; this.dataViewPort.lastItemRendererFactory = this._lastItemRendererFactory; this.dataViewPort.lastItemRendererName = this._lastItemRendererName; this.dataViewPort.singleItemRendererType = this._singleItemRendererType; this.dataViewPort.singleItemRendererFactory = this._singleItemRendererFactory; this.dataViewPort.singleItemRendererName = this._singleItemRendererName; this.dataViewPort.headerRendererType = this._headerRendererType; this.dataViewPort.headerRendererFactory = this._headerRendererFactory; this.dataViewPort.headerRendererProperties = this._headerRendererProperties; this.dataViewPort.headerRendererName = this._headerRendererName; this.dataViewPort.typicalHeader = this._typicalHeader; this.dataViewPort.footerRendererType = this._footerRendererType; this.dataViewPort.footerRendererFactory = this._footerRendererFactory; this.dataViewPort.footerRendererProperties = this._footerRendererProperties; this.dataViewPort.footerRendererName = this._footerRendererName; this.dataViewPort.typicalFooter = this._typicalFooter; this.dataViewPort.layout = this._layout; } /** * @private */ override protected function handlePendingScroll():void { if(this.pendingGroupIndex >= 0 && this.pendingItemIndex >= 0) { const item:Object = this._dataProvider.getItemAt(this.pendingGroupIndex, this.pendingItemIndex); if(item is Object) { this.dataViewPort.getScrollPositionForIndex(this.pendingGroupIndex, this.pendingItemIndex, HELPER_POINT); this.pendingGroupIndex = -1; this.pendingItemIndex = -1; if(this.pendingScrollDuration > 0) { this.throwTo(Math.max(0, Math.min(HELPER_POINT.x, this._maxHorizontalScrollPosition)), Math.max(0, Math.min(HELPER_POINT.y, this._maxVerticalScrollPosition)), this.pendingScrollDuration); } else { this.horizontalScrollPosition = Math.max(0, Math.min(HELPER_POINT.x, this._maxHorizontalScrollPosition)); this.verticalScrollPosition = Math.max(0, Math.min(HELPER_POINT.y, this._maxVerticalScrollPosition)); } } } super.handlePendingScroll(); } /** * @private */ protected function list_focusInHandler(event:Event):void { this.stage.addEventListener(KeyboardEvent.KEY_DOWN, stage_keyDownHandler); } /** * @private */ protected function list_focusOutHandler(event:Event):void { this.stage.removeEventListener(KeyboardEvent.KEY_DOWN, stage_keyDownHandler); } /** * @private */ protected function stage_keyDownHandler(event:KeyboardEvent):void { if(!this._dataProvider) { return; } if(event.keyCode == Keyboard.HOME) { if(this._dataProvider.getLength() > 0 && this._dataProvider.getLength(0) > 0) { this.setSelectedLocation(0, 0); } } if(event.keyCode == Keyboard.END) { var groupIndex:int = this._dataProvider.getLength(); var itemIndex:int = -1; do { groupIndex--; if(groupIndex >= 0) { itemIndex = this._dataProvider.getLength(groupIndex) - 1; } } while(groupIndex > 0 && itemIndex < 0) if(groupIndex >= 0 && itemIndex >= 0) { this.setSelectedLocation(groupIndex, itemIndex); } } else if(event.keyCode == Keyboard.UP) { groupIndex = this._selectedGroupIndex; itemIndex = this._selectedItemIndex - 1; if(itemIndex < 0) { do { groupIndex--; if(groupIndex >= 0) { itemIndex = this._dataProvider.getLength(groupIndex) - 1; } } while(groupIndex > 0 && itemIndex < 0) } if(groupIndex >= 0 && itemIndex >= 0) { this.setSelectedLocation(groupIndex, itemIndex); } } else if(event.keyCode == Keyboard.DOWN) { groupIndex = this._selectedGroupIndex; if(groupIndex < 0) { itemIndex = -1; } else { itemIndex = this._selectedItemIndex + 1; } if(groupIndex < 0 || itemIndex >= this._dataProvider.getLength(groupIndex)) { itemIndex = -1; groupIndex++; const groupCount:int = this._dataProvider.getLength(); while(groupIndex < groupCount && itemIndex < 0) { if(this._dataProvider.getLength(groupIndex) > 0) { itemIndex = 0; } else { groupIndex++; } } } if(groupIndex >= 0 && itemIndex >= 0) { this.setSelectedLocation(groupIndex, itemIndex); } } } /** * @private */ protected function dataProvider_resetHandler(event:Event):void { this.horizontalScrollPosition = 0; this.verticalScrollPosition = 0; } /** * @private */ protected function dataViewPort_changeHandler(event:Event):void { this.setSelectedLocation(this.dataViewPort.selectedGroupIndex, this.dataViewPort.selectedItemIndex); } } } ",12390,True,2946.7979181441397,median "/* GraphicsTest.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8glib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 16); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display // End of constructor list void u8g2_prepare(void) { u8g2.setFont(u8g2_font_6x10_tf); u8g2.setFontRefHeightExtendedText(); u8g2.setDrawColor(1); u8g2.setFontPosTop(); u8g2.setFontDirection(0); } void u8g2_box_title(uint8_t a) { u8g2.drawStr( 10+a*2, 5, ""U8g2""); u8g2.drawStr( 10, 20, ""GraphicsTest""); u8g2.drawFrame(0,0,u8g2.getDisplayWidth(),u8g2.getDisplayHeight() ); } void u8g2_box_frame(uint8_t a) { u8g2.drawStr( 0, 0, ""drawBox""); u8g2.drawBox(5,10,20,10); u8g2.drawBox(10+a,15,30,7); u8g2.drawStr( 0, 30, ""drawFrame""); u8g2.drawFrame(5,10+30,20,10); u8g2.drawFrame(10+a,15+30,30,7); } void u8g2_disc_circle(uint8_t a) { u8g2.drawStr( 0, 0, ""drawDisc""); u8g2.drawDisc(10,18,9); u8g2.drawDisc(24+a,16,7); u8g2.drawStr( 0, 30, ""drawCircle""); u8g2.drawCircle(10,18+30,9); u8g2.drawCircle(24+a,16+30,7); } void u8g2_r_frame(uint8_t a) { u8g2.drawStr( 0, 0, ""drawRFrame/Box""); u8g2.drawRFrame(5, 10,40,30, a+1); u8g2.drawRBox(50, 10,25,40, a+1); } void u8g2_string(uint8_t a) { u8g2.setFontDirection(0); u8g2.drawStr(30+a,31, "" 0""); u8g2.setFontDirection(1); u8g2.drawStr(30,31+a, "" 90""); u8g2.setFontDirection(2); u8g2.drawStr(30-a,31, "" 180""); u8g2.setFontDirection(3); u8g2.drawStr(30,31-a, "" 270""); } void u8g2_line(uint8_t a) { u8g2.drawStr( 0, 0, ""drawLine""); u8g2.drawLine(7+a, 10, 40, 55); u8g2.drawLine(7+a*2, 10, 60, 55); u8g2.drawLine(7+a*3, 10, 80, 55); u8g2.drawLine(7+a*4, 10, 100, 55); } void u8g2_triangle(uint8_t a) { uint16_t offset = a; u8g2.drawStr( 0, 0, ""drawTriangle""); u8g2.drawTriangle(14,7, 45,30, 10,40); u8g2.drawTriangle(14+offset,7-offset, 45+offset,30-offset, 57+offset,10-offset); u8g2.drawTriangle(57+offset*2,10, 45+offset*2,30, 86+offset*2,53); u8g2.drawTriangle(10+offset,40+offset, 45+offset,30+offset, 86+offset,53+offset); } void u8g2_ascii_1() { char s[2] = "" ""; uint8_t x, y; u8g2.drawStr( 0, 0, ""ASCII page 1""); for( y = 0; y < 6; y++ ) { for( x = 0; x < 16; x++ ) { s[0] = y*16 + x + 32; u8g2.drawStr(x*7, y*10+10, s); } } } void u8g2_ascii_2() { char s[2] = "" ""; uint8_t x, y; u8g2.drawStr( 0, 0, ""ASCII page 2""); for( y = 0; y < 6; y++ ) { for( x = 0; x < 16; x++ ) { s[0] = y*16 + x + 160; u8g2.drawStr(x*7, y*10+10, s); } } } void u8g2_extra_page(uint8_t a) { u8g2.drawStr( 0, 0, ""Unicode""); u8g2.setFont(u8g2_font_unifont_t_symbols); u8g2.setFontPosTop(); u8g2.drawUTF8(0, 24, ""☀ ☁""); switch(a) { case 0: case 1: case 2: case 3: u8g2.drawUTF8(a*3, 36, ""☂""); break; case 4: case 5: case 6: case 7: u8g2.drawUTF8(a*3, 36, ""☔""); break; } } void u8g2_xor(uint8_t a) { uint8_t i; u8g2.drawStr( 0, 0, ""XOR""); u8g2.setFontMode(1); u8g2.setDrawColor(2); for( i = 0; i < 5; i++) { u8g2.drawBox(10+i*16, 18 + (i&1)*4, 21,31); } u8g2.drawStr( 5+a, 19, ""XOR XOR XOR XOR""); u8g2.setDrawColor(0); u8g2.drawStr( 5+a, 29, ""CLR CLR CLR CLR""); u8g2.setDrawColor(1); u8g2.drawStr( 5+a, 39, ""SET SET SET SET""); u8g2.setFontMode(0); } #define cross_width 24 #define cross_height 24 static const unsigned char cross_bits[] U8X8_PROGMEM = { 0x00, 0x18, 0x00, 0x00, 0x24, 0x00, 0x00, 0x24, 0x00, 0x00, 0x42, 0x00, 0x00, 0x42, 0x00, 0x00, 0x42, 0x00, 0x00, 0x81, 0x00, 0x00, 0x81, 0x00, 0xC0, 0x00, 0x03, 0x38, 0x3C, 0x1C, 0x06, 0x42, 0x60, 0x01, 0x42, 0x80, 0x01, 0x42, 0x80, 0x06, 0x42, 0x60, 0x38, 0x3C, 0x1C, 0xC0, 0x00, 0x03, 0x00, 0x81, 0x00, 0x00, 0x81, 0x00, 0x00, 0x42, 0x00, 0x00, 0x42, 0x00, 0x00, 0x42, 0x00, 0x00, 0x24, 0x00, 0x00, 0x24, 0x00, 0x00, 0x18, 0x00, }; #define cross_fill_width 24 #define cross_fill_height 24 static const unsigned char cross_fill_bits[] U8X8_PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x64, 0x00, 0x26, 0x84, 0x00, 0x21, 0x08, 0x81, 0x10, 0x08, 0x42, 0x10, 0x10, 0x3C, 0x08, 0x20, 0x00, 0x04, 0x40, 0x00, 0x02, 0x80, 0x00, 0x01, 0x80, 0x18, 0x01, 0x80, 0x18, 0x01, 0x80, 0x00, 0x01, 0x40, 0x00, 0x02, 0x20, 0x00, 0x04, 0x10, 0x3C, 0x08, 0x08, 0x42, 0x10, 0x08, 0x81, 0x10, 0x84, 0x00, 0x21, 0x64, 0x00, 0x26, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; #define cross_block_width 14 #define cross_block_height 14 static const unsigned char cross_block_bits[] U8X8_PROGMEM = { 0xFF, 0x3F, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0xC1, 0x20, 0xC1, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0xFF, 0x3F, }; void u8g2_bitmap_overlay(uint8_t a) { uint8_t frame_size = 28; u8g2.drawStr(0, 0, ""Bitmap overlay""); u8g2.drawStr(0, frame_size + 12, ""Solid / transparent""); u8g2.setBitmapMode(false /* solid */); u8g2.drawFrame(0, 10, frame_size, frame_size); u8g2.drawXBMP(2, 12, cross_width, cross_height, cross_bits); if(a & 4) u8g2.drawXBMP(7, 17, cross_block_width, cross_block_height, cross_block_bits); u8g2.setBitmapMode(true /* transparent*/); u8g2.drawFrame(frame_size + 5, 10, frame_size, frame_size); u8g2.drawXBMP(frame_size + 7, 12, cross_width, cross_height, cross_bits); if(a & 4) u8g2.drawXBMP(frame_size + 12, 17, cross_block_width, cross_block_height, cross_block_bits); } void u8g2_bitmap_modes(uint8_t transparent) { const uint8_t frame_size = 24; u8g2.drawBox(0, frame_size * 0.5, frame_size * 5, frame_size); u8g2.drawStr(frame_size * 0.5, 50, ""Black""); u8g2.drawStr(frame_size * 2, 50, ""White""); u8g2.drawStr(frame_size * 3.5, 50, ""XOR""); if(!transparent) { u8g2.setBitmapMode(false /* solid */); u8g2.drawStr(0, 0, ""Solid bitmap""); } else { u8g2.setBitmapMode(true /* transparent*/); u8g2.drawStr(0, 0, ""Transparent bitmap""); } u8g2.setDrawColor(0);// Black u8g2.drawXBMP(frame_size * 0.5, 24, cross_width, cross_height, cross_bits); u8g2.setDrawColor(1); // White u8g2.drawXBMP(frame_size * 2, 24, cross_width, cross_height, cross_bits); u8g2.setDrawColor(2); // XOR u8g2.drawXBMP(frame_size * 3.5, 24, cross_width, cross_height, cross_bits); } uint8_t draw_state = 0; void draw(void) { u8g2_prepare(); switch(draw_state >> 3) { case 0: u8g2_box_title(draw_state&7); break; case 1: u8g2_box_frame(draw_state&7); break; case 2: u8g2_disc_circle(draw_state&7); break; case 3: u8g2_r_frame(draw_state&7); break; case 4: u8g2_string(draw_state&7); break; case 5: u8g2_line(draw_state&7); break; case 6: u8g2_triangle(draw_state&7); break; case 7: u8g2_ascii_1(); break; case 8: u8g2_ascii_2(); break; case 9: u8g2_extra_page(draw_state&7); break; case 10: u8g2_xor(draw_state&7); break; case 11: u8g2_bitmap_modes(0); break; case 12: u8g2_bitmap_modes(1); break; case 13: u8g2_bitmap_overlay(draw_state&7); break; } } void setup(void) { /* U8g2 Project: SSD1306 Test Board */ pinMode(10, OUTPUT); pinMode(9, OUTPUT); digitalWrite(10, 0); digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); u8g2.begin(); //u8g2.setFlipMode(0); } void loop(void) { // picture loop u8g2.firstPage(); do { draw(); } while( u8g2.nextPage() ); // increase the state draw_state++; if ( draw_state >= 14*8 ) draw_state = 0; // delay between each page delay(150); } ",16215,True,3592.0379464922257,median "/* Weather.ino Demonstrates: - Weather icons from open-iconic set. - Text scrolling. - Partial screen update This example requires display height >= 64. Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8g2lib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_WS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list #define SUN 0 #define SUN_CLOUD 1 #define CLOUD 2 #define RAIN 3 #define THUNDER 4 void drawWeatherSymbol(u8g2_uint_t x, u8g2_uint_t y, uint8_t symbol) { // fonts used: // u8g2_font_open_iconic_embedded_6x_t // u8g2_font_open_iconic_weather_6x_t // encoding values, see: https://github.com/olikraus/u8g2/wiki/fntgrpiconic switch(symbol) { case SUN: u8g2.setFont(u8g2_font_open_iconic_weather_6x_t); u8g2.drawGlyph(x, y, 69); break; case SUN_CLOUD: u8g2.setFont(u8g2_font_open_iconic_weather_6x_t); u8g2.drawGlyph(x, y, 65); break; case CLOUD: u8g2.setFont(u8g2_font_open_iconic_weather_6x_t); u8g2.drawGlyph(x, y, 64); break; case RAIN: u8g2.setFont(u8g2_font_open_iconic_weather_6x_t); u8g2.drawGlyph(x, y, 67); break; case THUNDER: u8g2.setFont(u8g2_font_open_iconic_embedded_6x_t); u8g2.drawGlyph(x, y, 67); break; } } void drawWeather(uint8_t symbol, int degree) { drawWeatherSymbol(0, 48, symbol); u8g2.setFont(u8g2_font_logisoso32_tf); u8g2.setCursor(48+3, 42); u8g2.print(degree); u8g2.print(""°C""); // requires enableUTF8Print() } /* Draw a string with specified pixel offset. The offset can be negative. Limitation: The monochrome font with 8 pixel per glyph */ void drawScrollString(int16_t offset, const char *s) { static char buf[36]; // should for screen with up to 256 pixel width size_t len; size_t char_offset = 0; u8g2_uint_t dx = 0; size_t visible = 0; u8g2.setDrawColor(0); // clear the scrolling area u8g2.drawBox(0, 49, u8g2.getDisplayWidth()-1, u8g2.getDisplayHeight()-1); u8g2.setDrawColor(1); // set the color for the text len = strlen(s); if ( offset < 0 ) { char_offset = (-offset)/8; dx = offset + char_offset*8; if ( char_offset >= u8g2.getDisplayWidth()/8 ) return; visible = u8g2.getDisplayWidth()/8-char_offset+1; strncpy(buf, s, visible); buf[visible] = '\\0'; u8g2.setFont(u8g2_font_8x13_mf); u8g2.drawStr(char_offset*8-dx, 62, buf); } else { char_offset = offset / 8; if ( char_offset >= len ) return; // nothing visible dx = offset - char_offset*8; visible = len - char_offset; if ( visible > u8g2.getDisplayWidth()/8+1 ) visible = u8g2.getDisplayWidth()/8+1; strncpy(buf, s+char_offset, visible); buf[visible] = '\\0'; u8g2.setFont(u8g2_font_8x13_mf); u8g2.drawStr(-dx, 62, buf); } } void draw(const char *s, uint8_t symbol, int degree) { int16_t offset = -(int16_t)u8g2.getDisplayWidth(); int16_t len = strlen(s); u8g2.clearBuffer(); // clear the internal memory drawWeather(symbol, degree); // draw the icon and degree only once for(;;) // then do the scrolling { drawScrollString(offset, s); // no clearBuffer required, screen will be partially cleared here u8g2.sendBuffer(); // transfer internal memory to the display delay(20); offset+=2; if ( offset > len*8+1 ) break; } } void setup(void) { /* U8g2 Project: SSD1306 Test Board */ pinMode(10, OUTPUT); pinMode(9, OUTPUT); digitalWrite(10, 0); digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); /* U8g2 Project: LC7981 Test Board, connect RW to GND */ //pinMode(17, OUTPUT); //digitalWrite(17, 0); /* U8g2 Project: Pax Instruments Shield: Enable Backlight */ //pinMode(6, OUTPUT); //digitalWrite(6, 0); u8g2.begin(); u8g2.enableUTF8Print(); } void loop(void) { draw(""What a beautiful day!"", SUN, 27); draw(""The sun's come out!"", SUN_CLOUD, 19); draw(""It's raining cats and dogs."", RAIN, 8); draw(""That sounds like thunder."", THUNDER, 12); draw(""It's stopped raining"", CLOUD, 15); } ",16236,True,4564.417100698121,median "//////////////////////////////////////////////////////////////////////////////// // // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the ""License""); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an ""AS IS"" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// package mx.controls { import flash.display.DisplayObject; import flash.events.Event; import flash.events.FocusEvent; import flash.events.KeyboardEvent; import flash.events.MouseEvent; import flash.events.TextEvent; import mx.collections.ArrayCollection; import mx.collections.CursorBookmark; import mx.collections.ICollectionView; import mx.collections.IList; import mx.collections.IViewCursor; import mx.collections.ListCollectionView; import mx.collections.XMLListCollection; import mx.core.EdgeMetrics; import mx.core.FlexVersion; import mx.core.IFlexDisplayObject; import mx.core.IIMESupport; import mx.core.IRectangularBorder; import mx.core.ITextInput; import mx.core.IUITextField; import mx.core.UIComponent; import mx.core.UITextField; import mx.core.mx_internal; import mx.events.CollectionEvent; import mx.events.CollectionEventKind; import mx.events.FlexEvent; import mx.managers.IFocusManager; import mx.managers.IFocusManagerComponent; import mx.styles.ISimpleStyleClient; import mx.styles.StyleProxy; import mx.utils.UIDUtil; use namespace mx_internal; /** * The alpha of the content background for this component. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ [Style(name=""contentBackgroundAlpha"", type=""Number"", inherit=""yes"", theme=""spark"")] /** * Color of the content area of the component. * * @default 0xFFFFFF * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ [Style(name=""contentBackgroundColor"", type=""uint"", format=""Color"", inherit=""yes"", theme=""spark"")] /** * Color of focus ring when the component is in focus * * @default 0x70B2EE * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ [Style(name=""focusColor"", type=""uint"", format=""Color"", inherit=""yes"", theme=""spark"")] /** * Color of any symbol of a component. Examples include the check mark of a CheckBox or * the arrow of a ScrollBar button. * * @default 0x000000 * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ [Style(name=""symbolColor"", type=""uint"", format=""Color"", inherit=""yes"", theme=""spark"")] /** * Name of the class to use as the default skin for the background and border. * For the ComboBase class, there is no default value. * For the ComboBox class, the default value is the ComboBoxArrowSkin class. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""skin"", type=""Class"", inherit=""no"", states="" up, over, down, disabled, editableUp, editableOver, editableDown, editableDisabled"")] /** * Name of the class to use as the skin for the background and border * when the mouse is not over the control. * For the ComboBase class, there is no default value. * For the ComboBox class, the default value is the ComboBoxArrowSkin class. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""upSkin"", type=""Class"", inherit=""no"")] /** * Name of the class to use as the skin for the background and border * when the mouse is over the control. * For the ComboBase class, there is no default value. * For the ComboBox class, the default value is the ComboBoxArrowSkin class. * For the ColorPicker class, the default value is the ColorPickerSkin class. * For the DateField class, the default value is the ScrollArrowDownSkin class. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""overSkin"", type=""Class"", inherit=""no"")] /** * Name of the class to use as the skin for the background and border * when the user holds down the mouse button. * For the ComboBase class, there is no default value. * For the ComboBox class, the default value is the ComboBoxArrowSkin class. * For the ColorPicker class, the default value is the ColorPickerSkin class. * For the DateField class, the default value is the ScrollArrowDownSkin class. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""downSkin"", type=""Class"", inherit=""no"")] /** * Name of the class to use as the skin for the background and border * when the control is disabled. * For the ComboBase class, there is no default value. * For the ComboBox class, the default value is the ComboBoxArrowSkin class. * For the ColorPicker class, the default value is the ColorPickerSkin class. * For the DateField class, the default value is the ScrollArrowDownSkin class. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""disabledSkin"", type=""Class"", inherit=""no"")] /** * Name of the class to use as the skin for the background and border * when the editable * property is true. This skin is only used by the ComboBox class. * For the ComboBase class, there is no default value. * For the ComboBox class, the default value is the ComboBoxArrowSkin class. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""editableSkin"", type=""Class"", inherit=""no"")] /** * Name of the class to use as the skin for the background and border * when the mouse is not over the control, and the editable * property is true. This skin is only used by the ComboBox class. * For the ComboBase class, there is no default value. * For the ComboBox class, the default value is the ComboBoxArrowSkin class. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""editableUpSkin"", type=""Class"", inherit=""no"")] /** * Name of the class to use as the skin for the background and border * when the mouse is over the control, and the editable * property is true. This skin is only used by the ComboBox class. * For the ComboBase class, there is no default value. * For the ComboBox class, the default value is the ComboBoxArrowSkin class. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""editableOverSkin"", type=""Class"", inherit=""no"")] /** * Name of the class to use as the skin for the background and border * when the user holds down the mouse button, and the editable * property is true. This skin is only used by the ComboBox class. * For the ComboBase class, there is no default value. * For the ComboBox class, the default value is the ComboBoxArrowSkin class. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""editableDownSkin"", type=""Class"", inherit=""no"")] /** * Name of the class to use as the skin for the background and border * when the control is disabled, and the editable * property is true. This skin is only used by the ComboBox class. * For the ComboBase class, there is no default value. * For the ComboBox class, the default value is the ComboBoxArrowSkin class. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""editableDisabledSkin"", type=""Class"", inherit=""no"")] /** * The class implementing ITextInput that is used by this component * to input text. * *

It can be set to either the mx.core.TextInput class * (to use the classic Halo TextInput control) * or the mx.controls.MXFTETextInput class * (to use the Spark TextInput component based on the Text Layout Framework * to get improved text rendering, including bidirectional layout).

* * @default mx.controls.TextInput * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ [Style(name=""textInputClass"", type=""Class"", inherit=""no"")] /** * The style declaration for the internal TextInput subcomponent * that displays the current selection. * If no value is specified, then the TextInput subcomponent uses * the default text styles defined by the ComboBase class. * * @default """" * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Style(name=""textInputStyleName"", type=""String"", inherit=""no"")] //-------------------------------------- // Other metadata //-------------------------------------- [AccessibilityClass(implementation=""mx.accessibility.ComboBaseAccImpl"")] /** * The ComboBase class is the base class for controls that display text in a * text field and have a button that causes a drop-down list to appear where * the user can choose which text to display. * The ComboBase class is not used directly as an MXML tag. * * @mxml * *

The <mx:ComboBase> tag inherits all the tag attributes * of its superclass, and adds the following tag attributes:

* *
 *  <mx:tagname
 *    Properties
 *    dataProvider=""null""
 *    editable=""false|true""
 *    imeMode=""null""
 *    restrict=""null""
 *    selectedIndex=""-1""
 *    selectedItem=""null""
 *    text=""""
 *     
 *    Styles
 *    disabledSkin=""Depends on class""
 *    downSkin=""Depends on class""
 *    editableDisabledSkin=""Depends on class""
 *    editableDownSkin=""Depends on class""
 *    editableOverSkin=""Depends on class""
 *    editableUpSkin=""Depends on class""
 *    overSkin=""Depends on class""
 *    textInputStyleName="""" 
 *    upSkin=""Depends on class""
 *
 *  />
 *  
* * @see mx.controls.Button * @see mx.controls.TextInput * @see mx.collections.ICollectionView * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public class ComboBase extends UIComponent implements IIMESupport, IFocusManagerComponent { include ""../core/Version.as""; //-------------------------------------------------------------------------- // // Class mixins // //-------------------------------------------------------------------------- /** * @private * Placeholder for mixin by ComboBaseAccImpl. */ mx_internal static var createAccessibilityImplementation:Function; //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * Constructor. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function ComboBase() { super(); tabEnabled = true; tabFocusEnabled = true; } //-------------------------------------------------------------------------- // // Variables // //-------------------------------------------------------------------------- /** * The ICollectionView of items this component displays. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected var collection:ICollectionView; /** * The main IViewCursor used to fetch items from the * dataProvider and pass the items to the renderers. * At the end of any sequence of code, it must always be positioned * at the topmost visible item on screen. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected var iterator:IViewCursor; /** * @private * A separate IViewCursor used to find indices of items and other things. * The collectionIterator can be at any place within the set of items. */ mx_internal var collectionIterator:IViewCursor; /** * @private * The internal object that draws the border. */ mx_internal var border:IFlexDisplayObject; /** * @private * The internal Button property that causes the drop-down list to appear. */ mx_internal var downArrowButton:Button; /** * @private */ mx_internal var wrapDownArrowButton:Boolean = true; /** * @private */ mx_internal var useFullDropdownSkin:Boolean = false; /** * @private */ private var selectedUID:String; /** * @private * A flag indicating that selection has changed */ mx_internal var selectionChanged:Boolean = false; /** * @private * A flag indicating that selectedIndex has changed */ mx_internal var selectedIndexChanged:Boolean = false; /** * @private * A flag indicating that selectedItem has changed */ mx_internal var selectedItemChanged:Boolean = false; /** * @private * Stores the old value of the borderStyle style */ mx_internal var oldBorderStyle:String; //-------------------------------------------------------------------------- // // Overridden properties // //-------------------------------------------------------------------------- //---------------------------------- // baselinePosition //---------------------------------- /** * @private * The baselinePosition of a ComboBase is calculated for its TextInput. */ override public function get baselinePosition():Number { if (!validateBaselinePosition()) return NaN; return textInput.y + textInput.baselinePosition; } //---------------------------------- // enabled //---------------------------------- /** * @private * Storage for enabled property. */ private var _enabled:Boolean = false; /** * @private */ private var enabledChanged:Boolean = false; [Inspectable(category=""General"", enumeration=""true,false"", defaultValue=""true"")] /** * @private */ override public function set enabled(value:Boolean):void { super.enabled = value; _enabled = value; enabledChanged = true; invalidateProperties(); } //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- //---------------------------------- // arrowButtonStyleFilters //---------------------------------- /** * Set of styles to pass from the ComboBase to the down arrow button * @see mx.styles.StyleProxy * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get arrowButtonStyleFilters():Object { return null; } //---------------------------------- // borderMetrics //---------------------------------- /** * Returns an EdgeMetrics object that has four properties: * left, top, right, * and bottom. * The value of each property is equal to the thickness of the * corresponding side of the border, expressed in pixels. * * @return EdgeMetrics object with the left, right, top, * and bottom properties. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get borderMetrics():EdgeMetrics { if (border && border is IRectangularBorder) return IRectangularBorder(border).borderMetrics; return EdgeMetrics.EMPTY; } //---------------------------------- // dataProvider //---------------------------------- [Bindable(""collectionChange"")] [Inspectable(category=""Data"")] /** * The set of items this component displays. This property is of type * Object because the derived classes can handle a variety of data * types such as Arrays, XML, ICollectionViews, and other classes. All * are converted into an ICollectionView and that ICollectionView is * returned if you get the value of this property; you will not get the * value you set if it was not an ICollectionView. * *

Setting this property will adjust the selectedIndex * property (and therefore the selectedItem property) if * the selectedIndex property has not otherwise been set. * If there is no prompt property, the selectedIndex * property will be set to 0; otherwise it will remain at -1, * the index used for the prompt string. * If the selectedIndex property has been set and * it is out of range of the new data provider, unexpected behavior is * likely to occur.

* * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get dataProvider():Object { return collection; } /** * @private */ public function set dataProvider(value:Object):void { if (value is Array) { collection = new ArrayCollection(value as Array); } else if (value is ICollectionView) { collection = ICollectionView(value); } else if (value is IList) { collection = new ListCollectionView(IList(value)); } else if (value is XMLList) { collection = new XMLListCollection(value as XMLList); } else { // convert it to an array containing this one item var tmp:Array = [value]; collection = new ArrayCollection(tmp); } // get an iterator for the displaying rows. The CollectionView's // main iterator is left unchanged so folks can use old DataSelector // methods if they want to iterator = collection.createCursor(); collectionIterator = collection.createCursor(); //IViewCursor(collection); // trace(""ListBase added change listener""); // weak listeners to collections and dataproviders collection.addEventListener(CollectionEvent.COLLECTION_CHANGE, collectionChangeHandler, false, 0, true); var event:CollectionEvent = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE); event.kind = CollectionEventKind.RESET; collectionChangeHandler(event); dispatchEvent(event); invalidateSize(); invalidateDisplayList(); } //---------------------------------- // editable //---------------------------------- /** * @private * Storage for editable property. */ private var _editable:Boolean = false; /** * @private */ mx_internal var editableChanged:Boolean = true; [Bindable(""editableChanged"")] [Inspectable(category=""General"", defaultValue=""false"")] /** * A flag that indicates whether the control is editable, * which lets the user directly type entries that are not specified * in the dataProvider, or not editable, which requires the user select * from the items in the dataProvider. * *

If true keyboard input will be entered in the * editable text field; otherwise it will be used as shortcuts to * select items in the dataProvider.

* * @default false. * This property is ignored by the DateField control. * * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get editable():Boolean { return _editable; } /** * @private */ public function set editable(value:Boolean):void { _editable = value; editableChanged = true; invalidateProperties(); dispatchEvent(new Event(""editableChanged"")); } //---------------------------------- // enableIME //---------------------------------- /** * A flag that indicates whether the IME should * be enabled when the component receives focus. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ public function get enableIME():Boolean { return editable; } //---------------------------------- // imeMode //---------------------------------- /** * @private */ private var _imeMode:String = null; /** * @copy mx.controls.TextInput#imeMode * * @default null * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 **/ public function get imeMode():String { return _imeMode; } /** * @private */ public function set imeMode(value:String):void { _imeMode = value; if (textInput) textInput.imeMode = _imeMode; } //---------------------------------- // restrict //---------------------------------- /** * @private * Storage for restrict property. */ private var _restrict:String; [Bindable(""restrictChanged"")] [Inspectable(category=""Other"")] /** * Set of characters that a user can or cannot enter into the text field. * * @default null * * @see flash.text.TextField#restrict * * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get restrict():String { return _restrict; } /** * @private */ public function set restrict(value:String):void { _restrict = value; invalidateProperties(); dispatchEvent(new Event(""restrictChanged"")); } //---------------------------------- // selectedIndex //---------------------------------- private var _selectedIndex:int = -1; [Bindable(""change"")] [Bindable(""valueCommit"")] [Inspectable(category=""General"", defaultValue=""-1"")] /** * The index in the data provider of the selected item. * If there is a prompt property, the selectedIndex * value can be set to -1 to show the prompt. * If there is no prompt, property then selectedIndex * will be set to 0 once a dataProvider is set. * *

If the ComboBox control is editable, the selectedIndex * property is -1 if the user types any text * into the text field.

* *

Unlike many other Flex properties that are invalidating (setting * them does not have an immediate effect), the selectedIndex and * selectedItem properties are synchronous; setting one immediately * affects the other.

* * @default -1 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get selectedIndex():int { return _selectedIndex; } /** * @private */ public function set selectedIndex(value:int):void { _selectedIndex = value; if (value == -1) { _selectedItem = null; selectedUID = null; } //2 code paths: one for before collection, one after if (!collection || collection.length == 0) { selectedIndexChanged = true; } else { if (value != -1) { value = Math.min(value, collection.length - 1); var bookmark:CursorBookmark = iterator.bookmark; var len:int = value; iterator.seek(CursorBookmark.FIRST, len); var data:Object = iterator.current; var uid:String = itemToUID(data); iterator.seek(bookmark, 0); _selectedIndex = value; _selectedItem = data; selectedUID = uid; } } selectionChanged = true; invalidateDisplayList(); dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT)); } //---------------------------------- // selectedItem //---------------------------------- /** * @private * Storage for the selectedItem property. */ private var _selectedItem:Object; [Bindable(""change"")] [Bindable(""valueCommit"")] [Inspectable(category=""General"", defaultValue=""null"")] /** * The item in the data provider at the selectedIndex. * *

If the data is an object or class instance, modifying * properties in the object or instance modifies the * dataProvider object but may not update the views * unless the instance is Bindable or implements IPropertyChangeNotifier * or a call to dataProvider.itemUpdated() occurs.

* * Setting the selectedItem property causes the * ComboBox control to select that item (display it in the text field and * set the selectedIndex) if it exists in the data provider. * If the ComboBox control is editable, the selectedItem * property is null if the user types any text * into the text field. * *

Unlike many other Flex properties that are invalidating (setting * them does not have an immediate effect), selectedIndex and * selectedItem are synchronous; setting one immediately * affects the other.

* * @default null; * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get selectedItem():Object { return _selectedItem; } /** * @private */ public function set selectedItem(data:Object):void { setSelectedItem(data); } /** * @private */ private function setSelectedItem(data:Object, clearFirst:Boolean = true):void { //2 code paths: one for before collection, one after if (!collection || collection.length == 0) { _selectedItem = data; selectedItemChanged = true; invalidateDisplayList(); return; } var found:Boolean = false; var listCursor:IViewCursor = collection.createCursor(); var i:int = 0; do { if (data == listCursor.current) { _selectedIndex = i; _selectedItem = data; selectedUID = itemToUID(data); selectionChanged = true; found = true; break; } i++; } while (listCursor.moveNext()); if (!found) { selectedIndex = -1; _selectedItem = null; selectedUID = null; } invalidateDisplayList(); } //---------------------------------- // text //---------------------------------- /** * @private * Storage for the text property. */ private var _text:String = """"; /** * @private */ mx_internal var textChanged:Boolean; [Bindable(""collectionChange"")] [Bindable(""valueCommit"")] [Inspectable(category=""General"", defaultValue="""")] [NonCommittingChangeEvent(""change"")] /** * Contents of the text field. If the control is non-editable * setting this property has no effect. If the control is editable, * setting this property sets the contents of the text field. * * @default """" * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get text():String { return _text; } /** * @private */ public function set text(value:String):void { _text = value; textChanged = true; invalidateProperties(); dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT)); } //---------------------------------- // textInput //---------------------------------- /** * The internal TextInput subcomponent that displays * the current selection. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected var textInput:ITextInput; //---------------------------------- // textInputStyleFilters //---------------------------------- /** * The set of styles to pass from the ComboBase to the text input. * These styles are ignored if you set * the textInputStyleName style property. * @see mx.styles.StyleProxy * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get textInputStyleFilters():Object { return _textInputStyleFilters; } private static var _textInputStyleFilters:Object = { ""backgroundAlpha"" : ""backgroundAlpha"", ""backgroundColor"" : ""backgroundColor"", ""backgroundImage"" : ""backgroundImage"", ""backgroundDisabledColor"" : ""backgroundDisabledColor"", ""backgroundSize"" : ""backgroundSize"", ""borderAlpha"" : ""borderAlpha"", ""borderColor"" : ""borderColor"", ""borderSides"" : ""borderSides"", ""borderStyle"" : ""borderStyle"", ""borderThickness"" : ""borderThickness"", ""dropShadowColor"" : ""dropShadowColor"", ""dropShadowEnabled"" : ""dropShadowEnabled"", ""embedFonts"" : ""embedFonts"", ""focusAlpha"" : ""focusAlpha"", ""focusBlendMode"" : ""focusBlendMode"", ""focusRoundedCorners"" : ""focusRoundedCorners"", ""focusThickness"" : ""focusThickness"", ""leading"" : ""leading"", ""paddingLeft"" : ""paddingLeft"", ""paddingRight"" : ""paddingRight"", ""shadowDirection"" : ""shadowDirection"", ""shadowDistance"" : ""shadowDistance"", ""textDecoration"" : ""textDecoration"" }; //---------------------------------- // value //---------------------------------- [Bindable(""change"")] [Bindable(""valueCommit"")] /** * The value of the selected item. If the item is a Number or String, * the value is the item. If the item is an object, the value is * the data property, if it exists, or the label * property, if it exists. * *

Note: Using the selectedItem property * is often preferable to using this property. The value * property exists for backward compatibility with older applications.

* * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get value():Object { if (_editable) return text; var item:Object = selectedItem; if (item == null || typeof(item) != ""object"") return item; // Note: the explicit comparison with null is important, because otherwise when // the data is zero, the label will be returned. See bug 183294 for an example. return item.data != null ? item.data : item.label; } //-------------------------------------------------------------------------- // // Overridden methods // //-------------------------------------------------------------------------- /** * @private */ override protected function initializeAccessibility():void { if (ComboBase.createAccessibilityImplementation != null) ComboBase.createAccessibilityImplementation(this); } /** * @private */ override protected function createChildren():void { super.createChildren(); // Create the border first, in the back. if (!border) { var borderClass:Class = getStyle(""borderSkin""); if (borderClass) { border = new borderClass(); if (border is IFocusManagerComponent) IFocusManagerComponent(border).focusEnabled = false; if (border is ISimpleStyleClient) ISimpleStyleClient(border).styleName = this; addChild(DisplayObject(border)); if (FlexVersion.compatibilityVersion >= FlexVersion.VERSION_4_0) border.visible = false; } } // Next, create the downArrowButton before creating the textInput, // because it can be as large as the entire control. if (!downArrowButton) { downArrowButton = new Button(); downArrowButton.styleName = new StyleProxy(this, arrowButtonStyleFilters); downArrowButton.focusEnabled = false; downArrowButton.tabEnabled = false; addChild(downArrowButton); downArrowButton.addEventListener(FlexEvent.BUTTON_DOWN, downArrowButton_buttonDownHandler); } // Create the textInput on top. if (!textInput) { var textInputStyleName:Object = getStyle(""textInputStyleName""); if (!textInputStyleName) textInputStyleName = new StyleProxy(this, textInputStyleFilters); // Mechanism to use MXFTETextInput. var textInputClass:Class = getStyle(""textInputClass""); if (!textInputClass || FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0) { textInput = new TextInput(); } else { textInput = new textInputClass(); } textInput.editable = _editable; editableChanged = true; // Don't show ESC characters in the text field. textInput.restrict = ""^\\u001b""; textInput.focusEnabled = false; textInput.mouseEnabled = textInput.mouseChildren = _editable; textInput.imeMode = _imeMode; textInput.styleName = textInputStyleName; textInput.addEventListener(Event.CHANGE, textInput_changeHandler); textInput.addEventListener(FlexEvent.ENTER, textInput_enterHandler); textInput.addEventListener(FocusEvent.FOCUS_IN, focusInHandler); textInput.addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler); textInput.addEventListener(FlexEvent.VALUE_COMMIT, textInput_valueCommitHandler); addChild(DisplayObject(textInput)); textInput.move(0, 0); textInput.parentDrawsFocus = true; } } /** * @private */ override public function styleChanged(styleProp:String):void { if (downArrowButton) downArrowButton.styleChanged(styleProp); if (textInput) textInput.styleChanged(styleProp); if (border && border is ISimpleStyleClient) ISimpleStyleClient(border).styleChanged(styleProp); super.styleChanged(styleProp); } /** * @private */ override protected function commitProperties():void { super.commitProperties(); // A TextField interprets restrict="""" as meaning // don't allow any characters, and restrict = null // as meaning allow all characters. // The former is useless (the TextField should be disabled // instead) and the latter is useful, but MXML doesn't // have a way to specify restrict = null. So Flex changes // the semantics of restrict="""" to mean allow all characters. textInput.restrict = _restrict; if (textChanged) { textInput.text = _text; textChanged = false; } if (enabledChanged) { textInput.enabled = _enabled; editableChanged = true; downArrowButton.enabled = _enabled; enabledChanged = false; } if (editableChanged) { editableChanged = false; var e:Boolean = _editable; if (wrapDownArrowButton == false) { if (e) { if (oldBorderStyle) setStyle(""borderStyle"", oldBorderStyle); } else { oldBorderStyle = getStyle(""borderStyle""); setStyle(""borderStyle"", ""comboNonEdit""); } } // Swap the button skins if we have different skins for editable and // non-editable states. if (useFullDropdownSkin) { if (e && getStyle(""editableSkin"") != null) downArrowButton.skinName = ""editableSkin""; else downArrowButton.skinName = ""skin""; downArrowButton.upSkinName = e ? ""editableUpSkin"" : ""upSkin""; downArrowButton.overSkinName = e ? ""editableOverSkin"" : ""overSkin""; downArrowButton.downSkinName = e ? ""editableDownSkin"" : ""downSkin""; downArrowButton.disabledSkinName = e ? ""editableDisabledSkin"" : ""disabledSkin""; downArrowButton.changeSkins(); downArrowButton.invalidateDisplayList(); } if (textInput) { textInput.editable = e; textInput.selectable = e; if (e) { textInput.removeEventListener(MouseEvent.MOUSE_DOWN, textInput_mouseEventHandler); textInput.removeEventListener(MouseEvent.MOUSE_UP, textInput_mouseEventHandler); textInput.removeEventListener(MouseEvent.ROLL_OVER, textInput_mouseEventHandler); textInput.removeEventListener(MouseEvent.ROLL_OUT, textInput_mouseEventHandler); textInput.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler); } else { // Trap all mouse actions on the textfield and feed them to the button textInput.addEventListener(MouseEvent.MOUSE_DOWN, textInput_mouseEventHandler); textInput.addEventListener(MouseEvent.MOUSE_UP, textInput_mouseEventHandler); textInput.addEventListener(MouseEvent.ROLL_OVER, textInput_mouseEventHandler); textInput.addEventListener(MouseEvent.ROLL_OUT, textInput_mouseEventHandler); textInput.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler); } } } } /** * Determines the measuredWidth and * measuredHeight properties of the control. * The measured width is the width of the widest text * in the dataProvider * plus the width of the drop-down button. * The measured height is the larger of either the button or the text. * If no data provider has been set or there are no items * in the data provider, the measuredWidth property is set to * UIComponent.DEFAULT_MEASURED_WIDTH and the * measuredHeight property is set * to UIComponent.DEFAULT_MEASURED_HEIGHT. * * @see mx.core.UIComponent#measure() * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ override protected function measure():void { super.measure(); var buttonWidth:Number = getStyle(""arrowButtonWidth""); var buttonHeight:Number = downArrowButton.getExplicitOrMeasuredHeight(); // Text fields have 4 pixels of white space added to each side // by the player, so fudge this amount. // If we don't have any data, measure a single space char for defaults if (collection && collection.length > 0) { var prefSize:Object = calculatePreferredSizeFromData(collection.length); var bm:EdgeMetrics = borderMetrics; var textWidth:Number = prefSize.width + bm.left + bm.right + 8; var textHeight:Number = prefSize.height + bm.top + bm.bottom + UITextField.TEXT_HEIGHT_PADDING; measuredMinWidth = measuredWidth = textWidth + buttonWidth; measuredMinHeight = measuredHeight = Math.max(textHeight, buttonHeight); } else { measuredMinWidth = DEFAULT_MEASURED_MIN_WIDTH; measuredWidth = DEFAULT_MEASURED_WIDTH; measuredMinHeight = DEFAULT_MEASURED_MIN_HEIGHT; measuredHeight = DEFAULT_MEASURED_HEIGHT; } // Add in the paddingTop and paddingBottom values var padding:Number = getStyle(""paddingTop"") + getStyle(""paddingBottom""); measuredMinHeight += padding; measuredHeight += padding; } /** * Sizes and positions the internal components in the given width * and height. The drop-down button is placed all the way to the right * and the text field fills the remaining area. * * @param unscaledWidth Specifies the width of the component, in pixels, * in the component's coordinates, regardless of the value of the * scaleX property of the component. * * @param unscaledHeight Specifies the height of the component, in pixels, * in the component's coordinates, regardless of the value of the * scaleY property of the component. * * @see mx.core.UIComponent#updateDisplayList() * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); var w:Number = unscaledWidth; var h:Number = unscaledHeight; var arrowWidth:Number = getStyle(""arrowButtonWidth""); var textInputHeight:Number = textInput.getExplicitOrMeasuredHeight(); if (isNaN(arrowWidth)) arrowWidth = 0; if (wrapDownArrowButton) { var vm:EdgeMetrics = borderMetrics; var wh:Number = h - vm.top - vm.bottom; downArrowButton.setActualSize(wh, wh); downArrowButton.move(w - arrowWidth - vm.right, vm.top); if (border) border.setActualSize(w, h); textInput.setActualSize(w - arrowWidth, textInputHeight); } else { if (!_editable && useFullDropdownSkin) { var paddingTop:Number = getStyle(""paddingTop""); var paddingBottom:Number = getStyle(""paddingBottom""); downArrowButton.move(0, 0); if (border) border.setActualSize(w, h); textInput.setActualSize(w - arrowWidth, textInputHeight); textInput.showBorderAndBackground(false); textInput.move(textInput.x, ((h - textInputHeight - paddingTop - paddingBottom) / 2) + paddingTop); downArrowButton.setActualSize(unscaledWidth, unscaledHeight); } else { downArrowButton.move(w - arrowWidth, 0); if (border) border.setActualSize(w - arrowWidth, h); textInput.setActualSize(w - arrowWidth, h); downArrowButton.setActualSize(arrowWidth, unscaledHeight); textInput.showBorderAndBackground(true); } } if (selectedItemChanged) { selectedItem = selectedItem; selectedItemChanged = false; selectedIndexChanged = false; } if (selectedIndexChanged) { selectedIndex = selectedIndex; selectedIndexChanged = false; } } /** * @private */ override public function setFocus():void { if (textInput && _editable) textInput.setFocus(); else super.setFocus(); } /** * @private */ override protected function isOurFocus(target:DisplayObject):Boolean { return target == textInput || super.isOurFocus(target); } //-------------------------------------------------------------------------- // // Methods // //-------------------------------------------------------------------------- /** * Determines default values of the height and width to use for the * entries in the drop-down list. * Each subclass of ComboBase must implement this method and return * an Object containing two properties: width and * height. * * @param numItems The number of items to check to determine the size. * * @return An Object with width and height * properties. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function calculatePreferredSizeFromData(numItems:int):Object { return null; } /** * Determines the UID for a dataProvider item. * Every dataProvider item must have or will be assigned a unique * identifier (UID). * * @param data A dataProvider item. * * @return A unique identifier. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function itemToUID(data:Object):String { if (!data) return ""null""; return UIDUtil.getUID(data); } //-------------------------------------------------------------------------- // // Overridden event handlers // //-------------------------------------------------------------------------- /** * @private */ override protected function focusInHandler(event:FocusEvent):void { super.focusInHandler(event); } /** * @private */ override protected function focusOutHandler(event:FocusEvent):void { super.focusOutHandler(event); var fm:IFocusManager = focusManager; if (fm && event.target == this) fm.defaultButtonEnabled = true; if (_editable) dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT)); } //-------------------------------------------------------------------------- // // Event handlers // //-------------------------------------------------------------------------- /** * Responds to changes to the data provider. The component will adjust * the selectedIndex property if items are added or removed * before the component's selected item. * * @param event The CollectionEvent dispatched from the collection. * * @see mx.events.CollectionEvent * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function collectionChangeHandler(event:Event):void { if (event is CollectionEvent) { var requiresValueCommit:Boolean = false; var len:Number; var ind:Object; var ce:CollectionEvent = CollectionEvent(event); if (ce.kind == CollectionEventKind.ADD) { if (selectedIndex >= ce.location) _selectedIndex++; } if (ce.kind == CollectionEventKind.REMOVE) { for (var i:int = 0; i < ce.items.length; i++) { var uid:String = itemToUID(ce.items[i]); if (selectedUID == uid) { selectionChanged = true; } } if (selectionChanged) { if (_selectedIndex >= collection.length) _selectedIndex = collection.length - 1; selectedIndexChanged = true; requiresValueCommit = true; invalidateDisplayList(); } else if (selectedIndex >= ce.location) { _selectedIndex--; selectedIndexChanged = true; requiresValueCommit = true; invalidateDisplayList(); } } if (ce.kind == CollectionEventKind.REFRESH) { selectedItemChanged = true; // Sorting always changes the selection array requiresValueCommit = true; } invalidateDisplayList(); if (requiresValueCommit) dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT)); } } /** * @private * Forward an event to the down arrow button. */ private function textInput_mouseEventHandler(event:Event):void { downArrowButton.dispatchEvent(event); } /** * Handles changes to the TextInput that serves as the editable * text field in the component. The method sets * selectedIndex to -1 (and therefore * selectedItem to null). * * @param event The event that is triggered each time the text in the control changes. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function textInput_changeHandler(event:Event):void { // update _text as the user types _text = textInput.text; if (_selectedIndex != -1) { _selectedIndex = -1; _selectedItem = null; selectedUID = null; } } /** * @private * valueCommit handler for the textInput */ private function textInput_valueCommitHandler(event:FlexEvent):void { // update _text if textInput.text is changed programatically _text = textInput.text; dispatchEvent(event); } /** * @private */ private function textInput_enterHandler(event:FlexEvent):void { dispatchEvent(event); dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT)); } /** * Performs some action when the drop-down button is pressed. This is * an abstract base class implementation, so it has no effect and is * overridden by the subclasses. * * @param event The event that is triggered when the drop-down button is pressed. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function downArrowButton_buttonDownHandler(event:FlexEvent):void { // overridden by subclasses } /** * @private */ mx_internal function getTextInput():ITextInput { return textInput; } /** * @private */ mx_internal function get ComboDownArrowButton():Button { return downArrowButton; } } } ",12080,False,2232.2848698424536,median "#include /* TimeLapseAvi ESP32-CAM Video Recorder This program records an AVI video on the SD Card of an ESP32-CAM. by James Zahary July 20, 2019 TimeLapseAvi23x.ino jamzah.plc@gmail.com https://github.com/jameszah/ESP32-CAM-Video-Recorder jameszah/ESP32-CAM-Video-Recorder is licensed under the GNU General Public License v3.0 The is Arduino code, with standard setup for ESP32-CAM - Board ESP32 Wrover Module - Partition Scheme Huge APP (3MB No OTA) */ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // edit these parameters for your needs static const char vernum[] = ""v20061""; static const char devname[] = ""desklens""; // name of your camera for mDNS, Router, and filenames #define TIMEZONE ""CST-8"" // your timezone - this is GMT // 1 for blink red led with every sd card write, at your frame rate // 0 for blink only for skipping frames and SOS if camera or sd is broken #define BlinkWithWrite 0 // EDIT ssid and password const char ssid[] = ""LinkTest""; // your wireless network name (SSID) const char password[] = ""87654321""; // your Wi-Fi network password // startup defaults for first recording // here are the recording options from the ""retart web page"" // VGA 10 fps for 30 min, repeat, realtime http://192.168.0.117/start?framesize=VGA&length=1800&interval=100&quality=10&repeat=100&speed=1&gray=0 // VGA 2 fps, for 30 minutes repeat, 30x playback http://192.168.0.117/start?framesize=VGA&length=1800&interval=500&quality=10&repeat=300&speed=30&gray=0 // UXGA 1 sec per frame, for 30 minutes repeat, 30x playback http://192.168.0.117/start?framesize=UXGA&length=1800&interval=1000&quality=10&repeat=100&speed=30&gray=0 // UXGA 2 fps for 30 minutes repeat, 15x playback http://192.168.0.117/start?framesize=UXGA&length=1800&interval=500&quality=10&repeat=100&speed=30&gray=0 // CIF 20 fps second for 30 minutes repeat http://192.168.0.117/start?framesize=CIF&length=1800&interval=50&quality=10&repeat=100&speed=1&gray=0 // reboot startup parameters here int record_on_reboot = 0; // set to 1 to record, or 0 to NOT record on reboot int framesize = 7; // vga (10 UXGA, 7 SVGA, 6 VGA, 5 CIF) int repeat = 100; // 100 files int xspeed = 1; // 1x playback speed (realtime is 1) int gray = 0; // not gray int quality = 10; // 10 on the 0..64 scale, or 10..50 subscale - 10 is good, 20 is grainy and smaller files int capture_interval = 100; // 100 ms or 10 frames per second int total_frames = 18000; // 18000 frames = 10 fps * 60 seconds * 30 minutes = half hour int PIRpin = 12; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int new_config = 5; // this system abandoned ! int xlength = total_frames * capture_interval / 1000; int recording = 0; int PIRstatus = 0; int PIRrecording = 0; int ready = 0; //#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE #include ""esp_log.h"" #include ""esp_http_server.h"" #include ""esp_camera.h"" #include #include ""ESP32FtpServer.h"" #include FtpServer ftpSrv; //set #define FTP_DEBUG in ESP32FtpServer.h to see ftp verbose on serial // Time #include ""time.h"" // MicroSD #include ""driver/sdmmc_host.h"" #include ""driver/sdmmc_defs.h"" #include ""sdmmc_cmd.h"" #include ""esp_vfs_fat.h"" #include long current_millis; long last_capture_millis = 0; static esp_err_t cam_err; static esp_err_t card_err; char strftime_buf[64]; int file_number = 0; bool internet_connected = false; struct tm timeinfo; time_t now; char *filename ; char *stream ; int newfile = 0; int frames_so_far = 0; FILE *myfile; long bp; long ap; long bw; long aw; long totalp; long totalw; float avgp; float avgw; int overtime_count = 0; // CAMERA_MODEL_AI_THINKER #define PWDN_GPIO_NUM 32 #define RESET_GPIO_NUM -1 #define XCLK_GPIO_NUM 0 #define SIOD_GPIO_NUM 26 #define SIOC_GPIO_NUM 27 #define Y9_GPIO_NUM 35 #define Y8_GPIO_NUM 34 #define Y7_GPIO_NUM 39 #define Y6_GPIO_NUM 36 #define Y5_GPIO_NUM 21 #define Y4_GPIO_NUM 19 #define Y3_GPIO_NUM 18 #define Y2_GPIO_NUM 5 #define VSYNC_GPIO_NUM 25 #define HREF_GPIO_NUM 23 #define PCLK_GPIO_NUM 22 // GLOBALS #define BUFFSIZE 512 // global variable used by these pieces char str[20]; uint16_t n; uint8_t buf[BUFFSIZE]; static int i = 0; uint8_t temp = 0, temp_last = 0; unsigned long fileposition = 0; uint16_t frame_cnt = 0; uint16_t remnant = 0; uint32_t length = 0; uint32_t startms; uint32_t elapsedms; uint32_t uVideoLen = 0; bool is_header = false; long bigdelta = 0; int other_cpu_active = 0; int skipping = 0; int skipped = 0; int fb_max = 12; camera_fb_t * fb_q[30]; int fb_in = 0; int fb_out = 0; camera_fb_t * fb = NULL; FILE *avifile = NULL; FILE *idxfile = NULL; #define AVIOFFSET 240 // AVI main header length unsigned long movi_size = 0; unsigned long jpeg_size = 0; unsigned long idx_offset = 0; uint8_t zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; uint8_t dc_buf[4] = {0x30, 0x30, 0x64, 0x63}; // ""00dc"" uint8_t avi1_buf[4] = {0x41, 0x56, 0x49, 0x31}; // ""AVI1"" uint8_t idx1_buf[4] = {0x69, 0x64, 0x78, 0x31}; // ""idx1"" uint8_t vga_w[2] = {0x80, 0x02}; // 640 uint8_t vga_h[2] = {0xE0, 0x01}; // 480 uint8_t cif_w[2] = {0x90, 0x01}; // 400 uint8_t cif_h[2] = {0x28, 0x01}; // 296 uint8_t svga_w[2] = {0x20, 0x03}; // 800 uint8_t svga_h[2] = {0x58, 0x02}; // 600 uint8_t uxga_w[2] = {0x40, 0x06}; // 1600 uint8_t uxga_h[2] = {0xB0, 0x04}; // 1200 const int avi_header[AVIOFFSET] PROGMEM = { 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x4E, 0x46, 0x4F, 0x10, 0x00, 0x00, 0x00, 0x6A, 0x61, 0x6D, 0x65, 0x73, 0x7A, 0x61, 0x68, 0x61, 0x72, 0x79, 0x20, 0x76, 0x36, 0x30, 0x20, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, }; bool timeSet = 0;//未设置系统时间 暂停移动侦测 // Motion detection test - looks for diffs between camera images. #include ""motionDetect.h"" bool debug = true; uint8_t fsizePtr = FRAMESIZE_SVGA; // framesize selection uint8_t lightLevel; // Current ambient light level uint8_t nightSwitch = 10; // white level % for night/day switching uint8_t motionVal = 7; // motion sensitivity difference setting bool haveMotion = false; long lastDetection = 0;//上一次检测的时间 struct frameStruct { const char* frameSizeStr; const uint16_t frameWidth; const uint16_t frameHeight; const uint16_t defaultFPS; const uint8_t scaleFactor; const uint8_t sampleRate; }; // sample factors, 5th arg is scaling factor (1..N), 6th arg is sample factor (0..3) // indexed by frame size - needs to be consistent with sensor.h enum // #include ""sensor.h"" extern const frameStruct frameData[] = { {""QQVGA"", 160, 120, 25, 2, 1}, {""n/a"", 0, 0, 0, 0, 1}, {""n/a"", 0, 0, 0, 0, 1}, {""HQVGA"", 240, 176, 25, 3, 1}, {""QVGA"", 320, 240, 25, 3, 1}, {""CIF"", 400, 296, 25, 3, 1}, {""VGA"", 640, 480, 15, 3, 2}, {""SVGA"", 800, 600, 10, 3, 2}, {""XGA"", 1024, 768, 5, 3, 3}, {""SXGA"", 1280, 1024, 3, 3, 4}, {""UXGA"", 1600, 1200, 2, 6, 5} }; bool motionDetection(camera_fb_t* fb, bool motionStatus); bool isNight(uint8_t nightSwitch); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // AviWriterTask runs on cpu 1 to write the avi file // TaskHandle_t CameraTask, AviWriterTask; SemaphoreHandle_t baton; int counter = 0; void codeForAviWriterTask( void * parameter ) { for (;;) { if (ready) { make_avi(); } delay(1); } } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // CameraTask runs on cpu 0 to take pictures and drop them in a queue // void codeForCameraTask( void * parameter ) { for (;;) { if (other_cpu_active == 1 ) { current_millis = millis(); if (current_millis - last_capture_millis > capture_interval) { last_capture_millis = millis(); xSemaphoreTake( baton, portMAX_DELAY ); if ( ( (fb_in + fb_max - fb_out) % fb_max) + 1 == fb_max ) { xSemaphoreGive( baton ); Serial.print("" Queue Full, Skipping ... ""); // the queue is full skipped++; skipping = 1; } if (skipping > 0 ) { if (!BlinkWithWrite) { digitalWrite(33, LOW); } if (skipping % 2 == 0) { // skip every other frame until queue is cleared frames_so_far = frames_so_far + 1; frame_cnt++; fb_in = (fb_in + 1) % fb_max; bp = millis(); fb_q[fb_in] = esp_camera_fb_get(); totalp = totalp - bp + millis(); } else { Serial.print(((fb_in + fb_max - fb_out) % fb_max)); // skip an extra frame to empty the queue skipped++; } skipping = skipping + 1; if (((fb_in + fb_max - fb_out) % fb_max) == 0 ) { skipping = 0; Serial.println("" Queue cleared. ""); } xSemaphoreGive( baton ); } else { skipping = 0; frames_so_far = frames_so_far + 1; frame_cnt++; fb_in = (fb_in + 1) % fb_max; bp = millis(); fb_q[fb_in] = esp_camera_fb_get(); totalp = totalp - bp + millis(); xSemaphoreGive( baton ); } } } delay(1); } } // // Writes an uint32_t in Big Endian at current file position // static void inline print_quartet(unsigned long i, FILE * fd) { uint8_t x[1]; x[0] = i % 0x100; size_t i1_err = fwrite(x , 1, 1, fd); i = i >> 8; x[0] = i % 0x100; size_t i2_err = fwrite(x , 1, 1, fd); i = i >> 8; x[0] = i % 0x100; size_t i3_err = fwrite(x , 1, 1, fd); i = i >> 8; x[0] = i % 0x100; size_t i4_err = fwrite(x , 1, 1, fd); } void startCameraServer(); httpd_handle_t camera_httpd = NULL; char the_page[3000]; char localip[20]; WiFiEventId_t eventID; #include ""soc/soc.h"" #include ""soc/rtc_cntl_reg.h"" //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // setup() runs on cpu 1 // void setup() { WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector // creates other problems delay(1000);//电容充电 Serial.begin(115200); Serial.setDebugOutput(true); // zzz Serial.println("" ""); Serial.println(""-------------------------------------""); Serial.printf(""ESP-CAM Video Recorder %s\\n"", vernum); Serial.printf("" http://%s.local - to access the camera\\n"", devname); Serial.println(""-------------------------------------""); pinMode(33, OUTPUT); // little red led on back of chip digitalWrite(33, LOW); // turn on the red LED on the back of chip if (init_wifi()) { // Connected to WiFi internet_connected = true; } // init_time();//离线模式不需要设置时间 if (!psramFound()) { Serial.println(""paraFound wrong - major fail""); major_fail(); } // SD camera init card_err = init_sdcard(); if (card_err != ESP_OK) { Serial.printf(""SD Card init failed with error 0x%x"", card_err); major_fail(); return; } startCameraServer(); // zzz username and password for ftp server ftpSrv.begin(""esp"", ""esp""); Serial.printf(""Total space: %lluMB\\n"", SD_MMC.totalBytes() / (1024 * 1024)); Serial.printf(""Used space: %lluMB\\n"", SD_MMC.usedBytes() / (1024 * 1024)); digitalWrite(33, HIGH); // red light turns off when setup is complete baton = xSemaphoreCreateMutex(); xTaskCreatePinnedToCore( codeForCameraTask, ""CameraTask"", 10000, NULL, 1, &CameraTask, 0); delay(50); xTaskCreatePinnedToCore( codeForAviWriterTask, ""AviWriterTask"", 10000, NULL, 2, &AviWriterTask, 1); delay(50); recording = 0; // we are NOT recording config_camera(); pinMode(4, OUTPUT); // using 1 bit mode, shut off the Blinding Disk-Active Light digitalWrite(4, LOW); pinMode(PIRpin, INPUT_PULLDOWN); // or PULLDOWN for active high newfile = 0; // no file is open // don't fiddle with this! recording = record_on_reboot; ready = 1; Serial.print(""Camera Ready! Use 'http://""); Serial.print(WiFi.softAPIP()); Serial.println(""' to connect""); } // // if we have no camera, or sd card, then flash rear led on and off to warn the human SOS - SOS // void major_fail() { Serial.println("" ""); for (int i = 0; i < 10; i++) { // 10 loops or about 100 seconds then reboot digitalWrite(33, LOW); delay(150); digitalWrite(33, HIGH); delay(150); digitalWrite(33, LOW); delay(150); digitalWrite(33, HIGH); delay(150); digitalWrite(33, LOW); delay(150); digitalWrite(33, HIGH); delay(150); delay(1000); digitalWrite(33, LOW); delay(500); digitalWrite(33, HIGH); delay(500); digitalWrite(33, LOW); delay(500); digitalWrite(33, HIGH); delay(500); digitalWrite(33, LOW); delay(500); digitalWrite(33, HIGH); delay(500); delay(1000); Serial.print(""Major Fail ""); Serial.print(i); Serial.print("" / ""); Serial.println(10); } ESP.restart(); } void init_time(){ // configTime(0, 0, ""pool.ntp.org""); setenv(""TZ"", TIMEZONE, 1); // mountain time zone from #define at top tzset(); time_t now ; timeinfo = { 0 }; int retry = 0; const int retry_count = 10; delay(1000); time(&now); localtime_r(&now, &timeinfo); while (timeinfo.tm_year < (2016 - 1900) && ++retry < retry_count) { Serial.printf(""Waiting for system time to be set... (%d/%d) -- %d\\n"", retry, retry_count, timeinfo.tm_year); delay(1000); time(&now); localtime_r(&now, &timeinfo); } Serial.println(ctime(&now)); } bool init_wifi() { int connAttempts = 0; // WiFi.disconnect(true); WiFi.mode(WIFI_AP); // Set your Static IP address IPAddress local_IP(10, 10, 1, 1); // Set your Gateway IP address IPAddress gateway(10, 10, 1, 1); IPAddress subnet(255, 255, 255, 0); WiFi.setHostname(devname); //WiFi.printDiag(Serial); WiFi.softAP(ssid, password); delay(1000); // while (WiFi.status() != WL_CONNECTED ) { // delay(500); // Serial.print("".""); // if (connAttempts == 10) { // Serial.println(""Cannot connect - try again""); // WiFi.begin(ssid, password); // WiFi.printDiag(Serial); // } // if (connAttempts == 20) { // Serial.println(""Cannot connect - fail""); // WiFi.printDiag(Serial); // return false; // } // connAttempts++; // } Serial.println(""AP start""); sprintf(localip, ""%s"", WiFi.softAPIP().toString().c_str()); //WiFi.printDiag(Serial); if (!MDNS.begin(devname)) { Serial.println(""Error setting up MDNS responder!""); } else { Serial.printf(""mDNS responder started '%s'\\n"", devname); } return true; } static esp_err_t init_sdcard() { esp_err_t ret = ESP_FAIL; sdmmc_host_t host = SDMMC_HOST_DEFAULT(); host.flags = SDMMC_HOST_FLAG_1BIT; // using 1 bit mode host.max_freq_khz = SDMMC_FREQ_HIGHSPEED; sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT(); slot_config.width = 1; // using 1 bit mode //Serial.print(""Slot config width should be 4 width: ""); Serial.println(slot_config.width); esp_vfs_fat_sdmmc_mount_config_t mount_config = { .format_if_mount_failed = false, .max_files = 5, }; //pinMode(4, OUTPUT); // using 1 bit mode, shut off the Blinding Disk-Active Light //digitalWrite(4, LOW); sdmmc_card_t *card; Serial.println(""Mounting SD card...""); ret = esp_vfs_fat_sdmmc_mount(""/sdcard"", &host, &slot_config, &mount_config, &card); if (ret == ESP_OK) { Serial.println(""SD card mount successfully!""); } else { Serial.printf(""Failed to mount SD card VFAT filesystem. Error: %s"", esp_err_to_name(ret)); major_fail(); } sdmmc_card_print_info(stdout, card); Serial.print(""SD_MMC Begin: ""); Serial.println(SD_MMC.begin()); // required by ftp system ?? } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Make the avi move in 4 pieces // // make_avi() called in every loop, which calls below, depending on conditions // start_avi() - open the file and write headers // another_pic_avi() - write one more frame of movie // end_avi() - write the final parameters and close the file void make_avi( ) { //摄像头移动侦测 if (timeSet == 1)//当时间设置完才开始移动侦测 { // if (millis() - lastDetection > 200){ // xSemaphoreTake( baton, portMAX_DELAY ); // camera_fb_t* fb = esp_camera_fb_get(); // lastDetection = millis(); // if (fb) { // // uint8_t nightSwitch = 10; // white level % for night/day switching // // isNight(nightSwitch); // haveMotion = motionDetection(fb, haveMotion); // if (haveMotion == 1 && isNight(10)) // { // haveMotion = 0; // } // Serial.println(haveMotion); // esp_camera_fb_return(fb); // } else Serial.println(""detection:Failed to get frame""); // xSemaphoreGive( baton ); // if(millis() - lastDetection > 4000){ // haveMotion = false; // } // } if (haveMotion == 1) { if (PIRrecording == 1) { // keep recording for 15 more seconds if ( (millis() - startms) > (total_frames * capture_interval - 5000) ) { total_frames = total_frames + 10000 / capture_interval ; Serial.println(""Add another 10 seconds""); } } else { if ( recording == 0 && newfile == 0) { //start a pir recording with current parameters, except no repeat and 15 seconds Serial.println(""Start a PIR(by cam)""); PIRrecording = 1; repeat = 0; total_frames = 15000 / capture_interval; xlength = total_frames * capture_interval / 1000; recording = 1; } } } } // 红外热释电移动侦测 PIRstatus = digitalRead(PIRpin); if (PIRstatus == 1) { if (PIRrecording == 1) { // keep recording for 15 more seconds if ( (millis() - startms) > (total_frames * capture_interval - 5000) ) { // total_frames = total_frames + 10 * 1000 / capture_interval ; total_frames = total_frames + 10000 / capture_interval ; Serial.println(""Add another 10 seconds""); } } else { if ( recording == 0 && newfile == 0) { //start a pir recording with current parameters, except no repeat and 15 seconds Serial.println(""Start a PIR""); PIRrecording = 1; repeat = 0; total_frames = 15000 / capture_interval; xlength = total_frames * capture_interval / 1000; recording = 1; } } } // we are recording, but no file is open if (newfile == 0 && recording == 1) { // open the file digitalWrite(33, HIGH); newfile = 1; start_avi(); } else { // we have a file open, but not recording if (newfile == 1 && recording == 0) { // got command to close file digitalWrite(33, LOW); end_avi(); Serial.println(""Done capture due to command""); frames_so_far = total_frames; newfile = 0; // file is closed recording = 0; // DO NOT start another recording PIRrecording = 0; } else { if (newfile == 1 && recording == 1) { // regular recording if (frames_so_far >= total_frames) { // we are done the recording Serial.println(""Done capture for total frames!""); digitalWrite(33, LOW); // close the file end_avi(); frames_so_far = 0; newfile = 0; // file is closed if (repeat > 0) { recording = 1; // start another recording repeat = repeat - 1; } else { recording = 0; PIRrecording = 0; } } else if ((millis() - startms) > (total_frames * capture_interval)) { // time is up, even though we have not done all the frames Serial.println ("" ""); Serial.println(""Done capture for time""); Serial.print(""Time Elapsed: ""); Serial.print(millis() - startms); Serial.print("" Frames: ""); Serial.println(frame_cnt); Serial.print(""Config: ""); Serial.print(total_frames * capture_interval ) ; Serial.print("" (""); Serial.print(total_frames); Serial.print("" x ""); Serial.print(capture_interval); Serial.println("")""); digitalWrite(33, LOW); // close the file end_avi(); frames_so_far = 0; newfile = 0; // file is closed if (repeat > 0) { recording = 1; // start another recording repeat = repeat - 1; } else { recording = 0; PIRrecording = 0; } } else { // regular another_save_avi(); } } } } } static esp_err_t config_camera() { camera_config_t config; //Serial.println(""config camera""); if (new_config == 5) { config.ledc_channel = LEDC_CHANNEL_0; config.ledc_timer = LEDC_TIMER_0; config.pin_d0 = Y2_GPIO_NUM; config.pin_d1 = Y3_GPIO_NUM; config.pin_d2 = Y4_GPIO_NUM; config.pin_d3 = Y5_GPIO_NUM; config.pin_d4 = Y6_GPIO_NUM; config.pin_d5 = Y7_GPIO_NUM; config.pin_d6 = Y8_GPIO_NUM; config.pin_d7 = Y9_GPIO_NUM; config.pin_xclk = XCLK_GPIO_NUM; config.pin_pclk = PCLK_GPIO_NUM; config.pin_vsync = VSYNC_GPIO_NUM; config.pin_href = HREF_GPIO_NUM; config.pin_sscb_sda = SIOD_GPIO_NUM; config.pin_sscb_scl = SIOC_GPIO_NUM; config.pin_pwdn = PWDN_GPIO_NUM; config.pin_reset = RESET_GPIO_NUM; config.xclk_freq_hz = 20000000; config.pixel_format = PIXFORMAT_JPEG; config.frame_size = FRAMESIZE_UXGA; fb_max = 7; // for vga and uxga config.jpeg_quality = 8; config.fb_count = fb_max + 1; // camera init cam_err = esp_camera_init(&config); if (cam_err != ESP_OK) { Serial.printf(""Camera init failed with error 0x%x"", cam_err); major_fail(); } new_config = 2; } delay(100); sensor_t * ss = esp_camera_sensor_get(); ss->set_quality(ss, quality); ss->set_framesize(ss, (framesize_t)framesize); if (gray == 1) { ss->set_special_effect(ss, 2); // 0 regular, 2 grayscale } else { ss->set_special_effect(ss, 0); // 0 regular, 2 grayscale } for (int j = 0; j < 3; j++) { do_fb(); // start the camera ... warm it up delay(1); } } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // start_avi - open the files and write in headers // static esp_err_t start_avi() { Serial.println(""Starting an avi ""); config_camera(); time(&now); localtime_r(&now, &timeinfo); strftime(strftime_buf, sizeof(strftime_buf), ""%F_%H.%M.%S"", &timeinfo); char fname[100]; if (framesize == 6) { sprintf(fname, ""/sdcard/%s_%s_vga_Q%d_I%d_L%d_S%d.avi"", devname, strftime_buf, quality, capture_interval, xlength, xspeed); } else if (framesize == 7) { sprintf(fname, ""/sdcard/%s_%s_svga_Q%d_I%d_L%d_S%d.avi"", devname, strftime_buf, quality, capture_interval, xlength, xspeed); } else if (framesize == 10) { sprintf(fname, ""/sdcard/%s_%s_uxga_Q%d_I%d_L%d_S%d.avi"", devname, strftime_buf, quality, capture_interval, xlength, xspeed); } else if (framesize == 5) { sprintf(fname, ""/sdcard/%s_%s_cif_Q%d_I%d_L%d_S%d.avi"", devname, strftime_buf, quality, capture_interval, xlength, xspeed); } else { Serial.println(""Wrong framesize""); sprintf(fname, ""/sdcard/%s_%s_xxx_Q%d_I%d_L%d_S%d.avi"", devname, strftime_buf, quality, capture_interval, xlength, xspeed); } Serial.print(""\\nFile name will be >""); Serial.print(fname); Serial.println(""<""); avifile = fopen(fname, ""w""); idxfile = fopen(""/sdcard/idx.tmp"", ""w""); if (avifile != NULL) { //Serial.printf(""File open: %s\\n"", fname); } else { Serial.println(""Could not open file""); major_fail(); } if (idxfile != NULL) { //Serial.printf(""File open: %s\\n"", ""/sdcard/idx.tmp""); } else { Serial.println(""Could not open file""); major_fail(); } for ( i = 0; i < AVIOFFSET; i++) { char ch = pgm_read_byte(&avi_header[i]); buf[i] = ch; } size_t err = fwrite(buf, 1, AVIOFFSET, avifile); if (framesize == 6) { fseek(avifile, 0x40, SEEK_SET); err = fwrite(vga_w, 1, 2, avifile); fseek(avifile, 0xA8, SEEK_SET); err = fwrite(vga_w, 1, 2, avifile); fseek(avifile, 0x44, SEEK_SET); err = fwrite(vga_h, 1, 2, avifile); fseek(avifile, 0xAC, SEEK_SET); err = fwrite(vga_h, 1, 2, avifile); } else if (framesize == 10) { fseek(avifile, 0x40, SEEK_SET); err = fwrite(uxga_w, 1, 2, avifile); fseek(avifile, 0xA8, SEEK_SET); err = fwrite(uxga_w, 1, 2, avifile); fseek(avifile, 0x44, SEEK_SET); err = fwrite(uxga_h, 1, 2, avifile); fseek(avifile, 0xAC, SEEK_SET); err = fwrite(uxga_h, 1, 2, avifile); } else if (framesize == 7) { fseek(avifile, 0x40, SEEK_SET); err = fwrite(svga_w, 1, 2, avifile); fseek(avifile, 0xA8, SEEK_SET); err = fwrite(svga_w, 1, 2, avifile); fseek(avifile, 0x44, SEEK_SET); err = fwrite(svga_h, 1, 2, avifile); fseek(avifile, 0xAC, SEEK_SET); err = fwrite(svga_h, 1, 2, avifile); } else if (framesize == 5) { fseek(avifile, 0x40, SEEK_SET); err = fwrite(cif_w, 1, 2, avifile); fseek(avifile, 0xA8, SEEK_SET); err = fwrite(cif_w, 1, 2, avifile); fseek(avifile, 0x44, SEEK_SET); err = fwrite(cif_h, 1, 2, avifile); fseek(avifile, 0xAC, SEEK_SET); err = fwrite(cif_h, 1, 2, avifile); } fseek(avifile, AVIOFFSET, SEEK_SET); Serial.print(F(""\\nRecording "")); Serial.print(total_frames); Serial.println(F("" video frames ...\\n"")); startms = millis(); bigdelta = millis(); totalp = 0; totalw = 0; overtime_count = 0; jpeg_size = 0; movi_size = 0; uVideoLen = 0; idx_offset = 4; frame_cnt = 0; frames_so_far = 0; skipping = 0; skipped = 0; newfile = 1; other_cpu_active = 1; } // end of start avi //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // another_save_avi runs on cpu 1, saves another frame to the avi file // // the ""baton"" semaphore makes sure that only one cpu is using the camera subsystem at a time // static esp_err_t another_save_avi() { xSemaphoreTake( baton, portMAX_DELAY ); if (fb_in == fb_out) { // nothing to do xSemaphoreGive( baton ); } else { fb_out = (fb_out + 1) % fb_max; int fblen; fblen = fb_q[fb_out]->len; //xSemaphoreGive( baton ); if (BlinkWithWrite) { digitalWrite(33, LOW); } jpeg_size = fblen; movi_size += jpeg_size; uVideoLen += jpeg_size; bw = millis(); size_t dc_err = fwrite(dc_buf, 1, 4, avifile); size_t ze_err = fwrite(zero_buf, 1, 4, avifile); bw = millis(); size_t err = fwrite(fb_q[fb_out]->buf, 1, fb_q[fb_out]->len, avifile); if (err == 0 ) { Serial.println(""Error on avi write""); major_fail(); } totalw = totalw + millis() - bw; //xSemaphoreTake( baton, portMAX_DELAY ); esp_camera_fb_return(fb_q[fb_out]); // release that buffer back to the camera system xSemaphoreGive( baton ); remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; print_quartet(idx_offset, idxfile); print_quartet(jpeg_size, idxfile); idx_offset = idx_offset + jpeg_size + remnant + 8; jpeg_size = jpeg_size + remnant; movi_size = movi_size + remnant; if (remnant > 0) { size_t rem_err = fwrite(zero_buf, 1, remnant, avifile); } fileposition = ftell (avifile); // Here, we are at end of chunk (after padding) fseek(avifile, fileposition - jpeg_size - 4, SEEK_SET); // Here we are the the 4-bytes blank placeholder print_quartet(jpeg_size, avifile); // Overwrite placeholder with actual frame size (without padding) fileposition = ftell (avifile); fseek(avifile, fileposition + 6, SEEK_SET); // Here is the FOURCC ""JFIF"" (JPEG header) // Overwrite ""JFIF"" (still images) with more appropriate ""AVI1"" size_t av_err = fwrite(avi1_buf, 1, 4, avifile); fileposition = ftell (avifile); fseek(avifile, fileposition + jpeg_size - 10 , SEEK_SET); //Serial.println(""Write done""); //41 totalw = totalw + millis() - bw; //if (((fb_in + fb_max - fb_out) % fb_max) > 0 ) { // Serial.print(((fb_in + fb_max - fb_out) % fb_max)); Serial.print("" ""); //} digitalWrite(33, HIGH); } } // end of another_pic_avi //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // end_avi runs on cpu 1, empties the queue of frames, writes the index, and closes the files // static esp_err_t end_avi() { unsigned long current_end = 0; other_cpu_active = 0 ; // shuts down the picture taking program //Serial.print("" Write Q: ""); Serial.print((fb_in + fb_max - fb_out) % fb_max); Serial.print("" in/out ""); Serial.print(fb_in); Serial.print("" / ""); Serial.println(fb_out); for (int i = 0; i < fb_max; i++) { // clear the queue another_save_avi(); } //Serial.print("" Write Q: ""); Serial.print((fb_in + fb_max - fb_out) % fb_max); Serial.print("" in/out ""); Serial.print(fb_in); Serial.print("" / ""); Serial.println(fb_out); current_end = ftell (avifile); Serial.println(""End of avi - closing the files""); elapsedms = millis() - startms; float fRealFPS = (1000.0f * (float)frame_cnt) / ((float)elapsedms) * xspeed; float fmicroseconds_per_frame = 1000000.0f / fRealFPS; uint8_t iAttainedFPS = round(fRealFPS); uint32_t us_per_frame = round(fmicroseconds_per_frame); //Modify the MJPEG header from the beginning of the file, overwriting various placeholders fseek(avifile, 4 , SEEK_SET); print_quartet(movi_size + 240 + 16 * frame_cnt + 8 * frame_cnt, avifile); fseek(avifile, 0x20 , SEEK_SET); print_quartet(us_per_frame, avifile); unsigned long max_bytes_per_sec = movi_size * iAttainedFPS / frame_cnt; fseek(avifile, 0x24 , SEEK_SET); print_quartet(max_bytes_per_sec, avifile); fseek(avifile, 0x30 , SEEK_SET); print_quartet(frame_cnt, avifile); fseek(avifile, 0x8c , SEEK_SET); print_quartet(frame_cnt, avifile); fseek(avifile, 0x84 , SEEK_SET); print_quartet((int)iAttainedFPS, avifile); fseek(avifile, 0xe8 , SEEK_SET); print_quartet(movi_size + frame_cnt * 8 + 4, avifile); Serial.println(F(""\\n*** Video recorded and saved ***\\n"")); Serial.print(F(""Recorded "")); Serial.print(elapsedms / 1000); Serial.print(F(""s in "")); Serial.print(frame_cnt); Serial.print(F("" frames\\nFile size is "")); Serial.print(movi_size + 12 * frame_cnt + 4); Serial.print(F("" bytes\\nActual FPS is "")); Serial.print(fRealFPS, 2); Serial.print(F(""\\nMax data rate is "")); Serial.print(max_bytes_per_sec); Serial.print(F("" byte/s\\nFrame duration is "")); Serial.print(us_per_frame); Serial.println(F("" us"")); Serial.print(F(""Average frame length is "")); Serial.print(uVideoLen / frame_cnt); Serial.println(F("" bytes"")); Serial.print(""Average picture time (ms) ""); Serial.println( totalp / frame_cnt ); Serial.print(""Average write time (ms) ""); Serial.println( totalw / frame_cnt ); Serial.print(""Frames Skipped % ""); Serial.println( 100.0 * skipped / total_frames, 1 ); Serial.println(""Writing the index""); fseek(avifile, current_end, SEEK_SET); fclose(idxfile); size_t i1_err = fwrite(idx1_buf, 1, 4, avifile); print_quartet(frame_cnt * 16, avifile); idxfile = fopen(""/sdcard/idx.tmp"", ""r""); if (idxfile != NULL) { //Serial.printf(""File open: %s\\n"", ""/sdcard/idx.tmp""); } else { Serial.println(""Could not open file""); //major_fail(); } char * AteBytes; AteBytes = (char*) malloc (8); for (int i = 0; i < frame_cnt; i++) { size_t res = fread ( AteBytes, 1, 8, idxfile); size_t i1_err = fwrite(dc_buf, 1, 4, avifile); size_t i2_err = fwrite(zero_buf, 1, 4, avifile); size_t i3_err = fwrite(AteBytes, 1, 8, avifile); } free(AteBytes); fclose(idxfile); fclose(avifile); int xx = remove(""/sdcard/idx.tmp""); Serial.println(""---""); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // do_fb - just takes a picture and discards it // static esp_err_t do_fb() { xSemaphoreTake( baton, portMAX_DELAY ); camera_fb_t * fb = esp_camera_fb_get(); Serial.print(""Pic, len=""); Serial.println(fb->len); esp_camera_fb_return(fb); xSemaphoreGive( baton ); } //////////////////////////////////////////////////////////////////////////////////// // // some globals for the loop() // long wakeup; long last_wakeup = 0; void loop() { wakeup = millis(); if (wakeup - last_wakeup > (14 * 60 * 1000) ) { // 14 minutes last_wakeup = millis(); // do_time(); } ftpSrv.handleFTP(); //delay(1); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // static esp_err_t capture_handler(httpd_req_t *req) { camera_fb_t * fb = NULL; esp_err_t res = ESP_OK; char fname[100]; //xSemaphoreTake( baton, portMAX_DELAY ); fb = esp_camera_fb_get(); if (!fb) { Serial.println(""Camera capture failed""); httpd_resp_send_500(req); xSemaphoreGive( baton ); return ESP_FAIL; } file_number++; sprintf(fname, ""inline; filename=capture_%d.jpg"", file_number); httpd_resp_set_type(req, ""image/jpeg""); httpd_resp_set_hdr(req, ""Content-Disposition"", fname); size_t out_len, out_width, out_height; size_t fb_len = 0; fb_len = fb->len; res = httpd_resp_send(req, (const char *)fb->buf, fb->len); esp_camera_fb_return(fb); //xSemaphoreGive( baton ); return res; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // static esp_err_t stop_handler(httpd_req_t *req) { esp_err_t res = ESP_OK; recording = 0; Serial.println(""stopping recording""); do_stop(""Stopping previous recording""); httpd_resp_send(req, the_page, strlen(the_page)); return ESP_OK; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // static esp_err_t start_handler(httpd_req_t *req) { esp_err_t res = ESP_OK; char buf[80]; size_t buf_len; char new_res[20]; if (recording == 1) { const char* resp = ""You must Stop recording, before starting a new one. Start over ...""; httpd_resp_send(req, resp, strlen(resp)); return ESP_OK; return res; } else { //recording = 1; Serial.println(""starting recording""); sensor_t * s = esp_camera_sensor_get(); int new_interval = capture_interval; int new_length = capture_interval * total_frames; int new_framesize = s->status.framesize; int new_quality = s->status.quality; int new_repeat = 0; int new_xspeed = 1; int new_xlength = 3; int new_gray = 0; /* Serial.println(""""); Serial.println(""Current Parameters :""); Serial.print("" Capture Interval = ""); Serial.print(capture_interval); Serial.println("" ms""); Serial.print("" Length = ""); Serial.print(capture_interval * total_frames / 1000); Serial.println("" s""); Serial.print("" Quality = ""); Serial.println(new_quality); Serial.print("" Framesize = ""); Serial.println(new_framesize); Serial.print("" Repeat = ""); Serial.println(repeat); Serial.print("" Speed = ""); Serial.println(xspeed); */ buf_len = httpd_req_get_url_query_len(req) + 1; if (buf_len > 1) { if (httpd_req_get_url_query_str(req, buf, buf_len) == ESP_OK) { ESP_LOGI(TAG, ""Found URL query => %s"", buf); char param[32]; /* Get value of expected key from query string */ //Serial.println("" ... parameters""); if (httpd_query_key_value(buf, ""length"", param, sizeof(param)) == ESP_OK) { int x = atoi(param); if (x >= 5 && x <= 3600 * 24 ) { // 5 sec to 24 hours new_length = x; } ESP_LOGI(TAG, ""Found URL query parameter => length=%s"", param); } if (httpd_query_key_value(buf, ""repeat"", param, sizeof(param)) == ESP_OK) { int x = atoi(param); if (x >= 0 ) { new_repeat = x; } ESP_LOGI(TAG, ""Found URL query parameter => repeat=%s"", param); } if (httpd_query_key_value(buf, ""framesize"", new_res, sizeof(new_res)) == ESP_OK) { if (strcmp(new_res, ""UXGA"") == 0) { new_framesize = 10; } else if (strcmp(new_res, ""SVGA"") == 0) { new_framesize = 7; } else if (strcmp(new_res, ""VGA"") == 0) { new_framesize = 6; } else if (strcmp(new_res, ""CIF"") == 0) { new_framesize = 5; } else { Serial.println(""Only UXGA, SVGA, VGA, and CIF are valid!""); } ESP_LOGI(TAG, ""Found URL query parameter => framesize=%s"", new_res); } if (httpd_query_key_value(buf, ""quality"", param, sizeof(param)) == ESP_OK) { int x = atoi(param); if (x >= 10 && x <= 50) { // MINIMUM QUALITY 10 to save memory new_quality = x; } ESP_LOGI(TAG, ""Found URL query parameter => quality=%s"", param); } if (httpd_query_key_value(buf, ""speed"", param, sizeof(param)) == ESP_OK) { int x = atoi(param); if (x >= 1 && x <= 100) { new_xspeed = x; } ESP_LOGI(TAG, ""Found URL query parameter => speed=%s"", param); } if (httpd_query_key_value(buf, ""gray"", param, sizeof(param)) == ESP_OK) { int x = atoi(param); if (x == 1 ) { new_gray = x; } ESP_LOGI(TAG, ""Found URL query parameter => gray=%s"", param); } if (httpd_query_key_value(buf, ""interval"", param, sizeof(param)) == ESP_OK) { int x = atoi(param); if (x >= 1 && x <= 180000) { // 180,000 ms = 3 min new_interval = x; } ESP_LOGI(TAG, ""Found URL query parameter => interval=%s"", param); } } } framesize = new_framesize; capture_interval = new_interval; xlength = new_length; total_frames = new_length * 1000 / capture_interval; repeat = new_repeat; quality = new_quality; xspeed = new_xspeed; gray = new_gray; do_start(""Starting a new AVI""); httpd_resp_send(req, the_page, strlen(the_page)); recording = 1; return ESP_OK; } } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // void do_start(char *the_message) { Serial.print(""do_start ""); Serial.println(the_message); const char msg[] PROGMEM = R""rawliteral( %s ESP32-CAM Video Recorder

%s
ESP32-CAM Video Recorder %s


Message is %s


Recording = %d (1 is active)
Capture Interval = %d ms
Length = %d seconds
Quality = %d (10 best to 50 worst)
Framesize = %d (10 UXGA, 7 SVGA, 6 VGA, 5 CIF)
Repeat = %d
Speed = %d
Gray = %d



)rawliteral""; sprintf(the_page, msg, devname, devname, vernum, the_message, recording, capture_interval, capture_interval * total_frames / 1000, quality, framesize, repeat, xspeed, gray); //Serial.println(strlen(msg)); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // void do_stop(char *the_message) { Serial.print(""do_stop ""); Serial.println(the_message); const char msg[] PROGMEM = R""rawliteral( %s ESP32-CAM Video Recorder

%s
ESP32-CAM Video Recorder %s


Message is %s


http://%s/

http://%s/start?framesize=VGA&length=1800&interval=100&quality=10&repeat=100&speed=1&gray=0

VGA 2 fps, for 30 minutes repeat, 30x playback

UXGA 1 sec per frame, for 30 minutes repeat, 30x playback

UXGA 2 fps for 30 minutes repeat, 15x playback

CIF 20 fps second for 30 minutes repeat


)rawliteral""; sprintf(the_page, msg, devname, devname, vernum, the_message, localip, localip, localip, localip, localip, localip, localip, localip); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // void do_status(char *the_message) { Serial.print(""do_status ""); Serial.println(the_message); const char msg[] PROGMEM = R""rawliteral( %s ESP32-CAM Video Recorder

%s
ESP32-CAM Video Recorder %s
%s


Message is %s


Total SD Space is %d MB, Used SD Space is %d MB
Recording = %d (1 is active)
Frame %d of %d, Skipped %d

Capture Interval = %d ms
Length = %d seconds
Quality = %d (10 best to 50 worst)
Framesize = %d (10 UXGA, 7 SVGA, 6 VGA, 5 CIF)
Repeat = %d
Playback Speed = %d
Gray = %d

Commands as follows for your ESP's ip address:

http://%s/

http://%s/stop ... and restart
You must be stopped before restart or PIR

ftp://%s/

Username: esp, Password: esp ... to download the files

Red LED on back of ESP will flash with every frame (or skipped frames), and flash SOS if camera or sd card not working.

Check camera position with the frame below
Refresh page for more.


)rawliteral""; time(&now); const char *strdate = ctime(&now); //Serial.printf(""Total space: %lluMB\\n"", SD_MMC.totalBytes() / (1024 * 1024)); //Serial.printf(""Used space: %lluMB\\n"", SD_MMC.usedBytes() / (1024 * 1024)); int tot = SD_MMC.totalBytes() / (1024 * 1024); int use = SD_MMC.usedBytes() / (1024 * 1024); //Serial.print(strlen(msg)); Serial.print("" ""); sprintf(the_page, msg, devname, devname, vernum, strdate, the_message, tot, use, recording, frames_so_far, total_frames, skipped, capture_interval, capture_interval * total_frames / 1000, quality, framesize, repeat, xspeed, gray, localip, localip, localip, localip, localip, localip); //Serial.println(strlen(the_page)); } static esp_err_t time_handler(httpd_req_t *req) { char buf[80]; size_t buf_len = httpd_req_get_url_query_len(req) + 1; if (buf_len > 1) { if (httpd_req_get_url_query_str(req, buf, buf_len) == ESP_OK) { ESP_LOGI(TAG, ""Found URL query => %s"", buf); char param[32]; /* Get value of expected key from query string */ //Serial.println("" ... parameters""); int year = 0; int mon = 0; int day = 0; int hour = 0; int min = 0; int sec = 0; bool err = 0; if (httpd_query_key_value(buf, ""year"", param, sizeof(param)) == ESP_OK) { int x = atoi(param); Serial.println(x); if (x >= 1900 && x <= 2100 ) { year = x; err = 0; Serial.println(year); }else{ err = 1; } } if (httpd_query_key_value(buf, ""mon"", param, sizeof(param)) == ESP_OK) { int x = atoi(param); Serial.println(x); if (x >= 1 && x <= 12 ) { mon = x; err = 0; Serial.println(mon); }else{ err = 1; } } if (httpd_query_key_value(buf, ""day"", param, sizeof(param)) == ESP_OK) { int x = atoi(param); Serial.println(x); if (x >= 1 && x <= 31 ) { day = x; err = 0; Serial.println(day); }else{ err = 1; } } if (httpd_query_key_value(buf, ""hour"", param, sizeof(param)) == ESP_OK) { int x = atoi(param); Serial.println(x); if (x >= 0 && x <= 24 ) { hour = x; err = 0; Serial.println(hour); }else{ err = 1; } } if (httpd_query_key_value(buf, ""min"", param, sizeof(param)) == ESP_OK) { int x = atoi(param); Serial.println(x); if (x >= 0 && x <= 60 ) { min = x; err = 0; Serial.println(min); }else{ err = 1; } } if (httpd_query_key_value(buf, ""sec"", param, sizeof(param)) == ESP_OK) { int x = atoi(param); Serial.println(x); if (x >= 0 && x <= 60 ) { sec = x; err = 0; Serial.println(sec); }else{ err = 1; } } if (err != 1) { struct tm tmGet; tmGet.tm_year = year - 1900; tmGet.tm_mon = mon; tmGet.tm_mday = day; tmGet.tm_hour = hour; tmGet.tm_min = min; tmGet.tm_sec = sec; time_t t = mktime(&tmGet); printf(""Setting time: %s"", asctime(&tmGet)); timeval tmSet = { .tv_sec = t }; settimeofday(&tmSet, NULL); timeSet = 1;//时间设置完了 } } } const char msg[] PROGMEM = R""rawliteral(Time:%s )rawliteral""; struct tm timeinfo; getLocalTime(&timeinfo); sprintf(the_page, msg, asctime(&timeinfo) ); httpd_resp_send(req, the_page, strlen(the_page)); return ESP_OK; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // static esp_err_t index_handler(httpd_req_t *req) { do_status(""Refresh Status""); httpd_resp_send(req, the_page, strlen(the_page)); return ESP_OK; } void startCameraServer() { httpd_config_t config = HTTPD_DEFAULT_CONFIG(); httpd_uri_t index_uri = { .uri = ""/"", .method = HTTP_GET, .handler = index_handler, .user_ctx = NULL }; httpd_uri_t capture_uri = { .uri = ""/capture"", .method = HTTP_GET, .handler = capture_handler, .user_ctx = NULL }; httpd_uri_t file_stop = { .uri = ""/stop"", .method = HTTP_GET, .handler = stop_handler, .user_ctx = NULL }; httpd_uri_t file_start = { .uri = ""/start"", .method = HTTP_GET, .handler = start_handler, .user_ctx = NULL }; httpd_uri_t time_set = { .uri = ""/time"", .method = HTTP_GET, .handler = time_handler, .user_ctx = NULL }; if (httpd_start(&camera_httpd, &config) == ESP_OK) { httpd_register_uri_handler(camera_httpd, &index_uri); httpd_register_uri_handler(camera_httpd, &capture_uri); httpd_register_uri_handler(camera_httpd, &file_start); httpd_register_uri_handler(camera_httpd, &file_stop); httpd_register_uri_handler(camera_httpd, &time_set); } Serial.println(""Camera http started""); } ",16377,True,2688.743933257389,median "/* PrintProgmem.ino AVR Architecture: Use the (Arduino compatible) u8g2 function ""print"" to draw a string, which is located in PROGMEM. For string constants use the F() macro, but this example use global strings instead. Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8g2lib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1306_72X40_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_WS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_RAYSTAR_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_RAYSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7528_ERC16064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7528_ERC16064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_KS0713_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_KS0713_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7567_HEM6432_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_IST7920_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_IST7920_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_DEM240064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1617_JLX128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1617_JLX128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list void setup(void) { u8g2.begin(); } const char s[] PROGMEM = ""Progmem""; const char s1[] PROGMEM = ""ABC"" ; const char s2[] PROGMEM = ""DEF"" ; const char s3[] PROGMEM = ""GHI"" ; const char s4[] PROGMEM = ""JKL"" ; const char *a[] = { s1, s2, s3, s4 }; int i = 0; void loop(void) { u8g2.setFont(u8g2_font_ncenB14_tr); u8g2.firstPage(); do { u8g2.setCursor(0, 20); u8g2.print((class __FlashStringHelper *)s); // print a sting, located in PROGMEM u8g2.setCursor(0, 40); u8g2.print((class __FlashStringHelper *)a[i]); // print a sting (PROGMEM) via RAM array. } while ( u8g2.nextPage() ); delay(1000); i++; if ( i >= 4 ) i = 0; } ",16264,True,5075.840637104752,median "/* Feathers Copyright 2012-2013 Joshua Tynjala. All Rights Reserved. This program is free software. You can redistribute and/or modify it in accordance with the terms of the accompanying license agreement. */ package feathers.controls { import feathers.core.FeathersControl; import feathers.core.IFocusDisplayObject; import feathers.core.ITextRenderer; import feathers.core.IToggle; import feathers.core.PropertyProxy; import feathers.events.FeathersEventType; import feathers.system.DeviceCapabilities; import Loom2D.Math.Point; import Loom2D.Math.Rectangle; import flash.ui.Keyboard; import starling.animation.Transitions; import starling.animation.Tween; import Loom2D.Loom2D; import Loom2D.Display.DisplayObject; import Loom2D.Events.Event; import Loom2D.Events.KeyboardEvent; import Loom2D.Events.Touch; import Loom2D.Events.TouchEvent; import Loom2D.Events.TouchPhase; /** * @inheritDoc */ [Event(name=""change"",type=""starling.events.Event"")] /** * Similar to a light switch with on and off states. Generally considered an * alternative to a check box. * * @see http://wiki.starling-framework.org/feathers/toggle-switch * @see Check */ public class ToggleSwitch extends FeathersControl implements IToggle, IFocusDisplayObject { /** * @private */ private static const HELPER_POINT:Point = new Point(); /** * @private */ private static const HELPER_TOUCHES_VECTOR:Vector. = new []; /** * @private * The minimum physical distance (in inches) that a touch must move * before the scroller starts scrolling. */ private static const MINIMUM_DRAG_DISTANCE:Number = 0.04; /** * @private */ protected static const INVALIDATION_FLAG_THUMB_FACTORY:String = ""thumbFactory""; /** * @private */ protected static const INVALIDATION_FLAG_ON_TRACK_FACTORY:String = ""onTrackFactory""; /** * @private */ protected static const INVALIDATION_FLAG_OFF_TRACK_FACTORY:String = ""offTrackFactory""; /** * The ON and OFF labels will be aligned to the middle vertically, * based on the full character height of the font. * * @see #labelAlign */ public static const LABEL_ALIGN_MIDDLE:String = ""middle""; /** * The ON and OFF labels will be aligned to the middle vertically, * based on only the baseline value of the font. * * @see #labelAlign */ public static const LABEL_ALIGN_BASELINE:String = ""baseline""; /** * The toggle switch has only one track skin, stretching to fill the * full length of switch. In this layout mode, the on track is * displayed and fills the entire length of the toggle switch. The off * track will not exist. * * @see #trackLayoutMode */ public static const TRACK_LAYOUT_MODE_SINGLE:String = ""single""; /** * The toggle switch has two tracks, stretching to fill each side of the * scroll bar with the thumb in the middle. The tracks will be resized * as the thumb moves. This layout mode is designed for toggle switches * where the two sides of the track may be colored differently to better * differentiate between the on state and the off state. * * Since the width and height of the tracks will change, consider * sing a special display object such as a `Scale9Image`, * `Scale3Image` or a `TiledImage` that is * designed to be resized dynamically. * * @see #trackLayoutMode * @see feathers.display.Scale9Image * @see feathers.display.Scale3Image * @see feathers.display.TiledImage */ public static const TRACK_LAYOUT_MODE_ON_OFF:String = ""onOff""; /** * The default value added to the `nameList` of the off label. * * @see feathers.core.IFeathersControl#nameList */ public static const DEFAULT_CHILD_NAME_OFF_LABEL:String = ""feathers-toggle-switch-off-label""; /** * The default value added to the `nameList` of the on label. * * @see feathers.core.IFeathersControl#nameList */ public static const DEFAULT_CHILD_NAME_ON_LABEL:String = ""feathers-toggle-switch-on-label""; /** * The default value added to the `nameList` of the off track. * * @see feathers.core.IFeathersControl#nameList */ public static const DEFAULT_CHILD_NAME_OFF_TRACK:String = ""feathers-toggle-switch-off-track""; /** * The default value added to the `nameList` of the on track. * * @see feathers.core.IFeathersControl#nameList */ public static const DEFAULT_CHILD_NAME_ON_TRACK:String = ""feathers-toggle-switch-on-track""; /** * The default value added to the `nameList` of the thumb. * * @see feathers.core.IFeathersControl#nameList */ public static const DEFAULT_CHILD_NAME_THUMB:String = ""feathers-toggle-switch-thumb""; /** * @private */ protected static function defaultThumbFactory():Button { return new Button(); } /** * @private */ protected static function defaultOnTrackFactory():Button { return new Button(); } /** * @private */ protected static function defaultOffTrackFactory():Button { return new Button(); } /** * Constructor. */ public function ToggleSwitch() { super(); this.addEventListener(TouchEvent.TOUCH, toggleSwitch_touchHandler); this.addEventListener(Event.REMOVED_FROM_STAGE, toggleSwitch_removedFromStageHandler); } /** * The value added to the `nameList` of the off label. This * variable is `protected` so that sub-classes can customize * the on label name in their constructors instead of using the default * name defined by `DEFAULT_CHILD_NAME_ON_LABEL`. * * @see feathers.core.IFeathersControl#nameList */ protected var onLabelName:String = DEFAULT_CHILD_NAME_ON_LABEL; /** * The value added to the `nameList` of the on label. This * variable is `protected` so that sub-classes can customize * the off label name in their constructors instead of using the default * name defined by `DEFAULT_CHILD_NAME_OFF_LABEL`. * * @see feathers.core.IFeathersControl#nameList */ protected var offLabelName:String = DEFAULT_CHILD_NAME_OFF_LABEL; /** * The value added to the `nameList` of the on track. This * variable is `protected` so that sub-classes can customize * the on track name in their constructors instead of using the default * name defined by `DEFAULT_CHILD_NAME_ON_TRACK`. * * To customize the on track name without subclassing, see * `customOnTrackName`. * * @see #customOnTrackName * @see feathers.core.IFeathersControl#nameList */ protected var onTrackName:String = DEFAULT_CHILD_NAME_ON_TRACK; /** * The value added to the `nameList` of the off track. This * variable is `protected` so that sub-classes can customize * the off track name in their constructors instead of using the default * name defined by `DEFAULT_CHILD_NAME_OFF_TRACK`. * * To customize the off track name without subclassing, see * `customOffTrackName`. * * @see #customOffTrackName * @see feathers.core.IFeathersControl#nameList */ protected var offTrackName:String = DEFAULT_CHILD_NAME_OFF_TRACK; /** * The value added to the `nameList` of the thumb. This * variable is `protected` so that sub-classes can customize * the thumb name in their constructors instead of using the default * name defined by `DEFAULT_CHILD_NAME_THUMB`. * * To customize the thumb name without subclassing, see * `customThumbName`. * * @see #customThumbName * @see feathers.core.IFeathersControl#nameList */ protected var thumbName:String = DEFAULT_CHILD_NAME_THUMB; /** * The thumb sub-component. */ protected var thumb:Button; /** * The ""on"" text renderer sub-component. */ protected var onTextRenderer:ITextRenderer; /** * The ""off"" text renderer sub-component. */ protected var offTextRenderer:ITextRenderer; /** * The ""on"" track sub-component. */ protected var onTrack:Button; /** * The ""off"" track sub-component. */ protected var offTrack:Button; /** * @private */ protected var _paddingRight:Number = 0; /** * The minimum space, in pixels, between the switch's right edge and the * switch's content. */ public function get paddingRight():Number { return this._paddingRight; } /** * @private */ public function set paddingRight(value:Number):void { if(this._paddingRight == value) { return; } this._paddingRight = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _paddingLeft:Number = 0; /** * The minimum space, in pixels, between the switch's left edge and the * switch's content. */ public function get paddingLeft():Number { return this._paddingLeft; } /** * @private */ public function set paddingLeft(value:Number):void { if(this._paddingLeft == value) { return; } this._paddingLeft = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _showLabels:Boolean = true; /** * Determines if the labels should be drawn. The onTrackSkin and * offTrackSkin backgrounds may include the text instead. */ public function get showLabels():Boolean { return _showLabels; } /** * @private */ public function set showLabels(value:Boolean):void { if(this._showLabels == value) { return; } this._showLabels = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _showThumb:Boolean = true; /** * Determines if the thumb should be displayed. This stops interaction * while still displaying the background. */ public function get showThumb():Boolean { return this._showThumb; } /** * @private */ public function set showThumb(value:Boolean):void { if(this._showThumb == value) { return; } this._showThumb = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _trackLayoutMode:String = TRACK_LAYOUT_MODE_SINGLE; [Inspectable(type=""String"",enumeration=""single,onOff"")] /** * Determines how the on and off track skins are positioned and sized. * * @default TRACK_LAYOUT_MODE_SINGLE * @see #TRACK_LAYOUT_MODE_SINGLE * @see #TRACK_LAYOUT_MODE_ON_OFF */ public function get trackLayoutMode():String { return this._trackLayoutMode; } /** * @private */ public function set trackLayoutMode(value:String):void { if(this._trackLayoutMode == value) { return; } this._trackLayoutMode = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _defaultLabelProperties:Dictionary.; /** * The default label properties are a set of key/value pairs to be * passed down to the toggle switch's label text renderers, and it is * used when no specific properties are defined for a specific label * text renderer's current state. The label text renderers are `ITextRenderer` * instances. The available properties depend on which `ITextRenderer` * implementation is returned by `labelFactory`. The most * common implementations are `BitmapFontTextRenderer` and * `TextFieldTextRenderer`. * * @see #labelFactory * @see feathers.core.ITextRenderer * @see feathers.core.BitmapFontTextRenderer * @see feathers.core.TextFieldTextRenderer * @see #onLabelProperties * @see #offLabelProperties * @see #disabledLabelProperties */ public function get defaultLabelProperties():Dictionary. { if(!this._defaultLabelProperties) { this._defaultLabelProperties = new Dictionary.; } return this._defaultLabelProperties; } /** * @private */ public function set defaultLabelProperties(value:Dictionary.):void { this._defaultLabelProperties = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _disabledLabelProperties:Dictionary.; /** * A set of key/value pairs to be passed down to the toggle switch's * label text renderers when the toggle switch is disabled. The label * text renderers are `ITextRenderer` instances. The * available properties depend on which `ITextRenderer` * implementation is returned by `labelFactory`. The most * common implementations are `BitmapFontTextRenderer` and * `TextFieldTextRenderer`. * * @see #labelFactory * @see feathers.core.ITextRenderer * @see feathers.core.BitmapFontTextRenderer * @see feathers.core.TextFieldTextRenderer * @see #defaultLabelProperties */ public function get disabledLabelProperties():Dictionary. { if(!this._disabledLabelProperties) { this._disabledLabelProperties = new Dictionary.; } return this._disabledLabelProperties; } /** * @private */ public function set disabledLabelProperties(value:Dictionary.):void { this._disabledLabelProperties = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _onLabelProperties:Dictionary.; /** * A set of key/value pairs to be passed down to the toggle switch's * ON label text renderer. If `null`, then * `defaultLabelProperties` is used instead. The label text * renderers are `ITextRenderer` instances. The available * properties depend on which `ITextRenderer` implementation * is returned by `labelFactory`. The most common * implementations are `BitmapFontTextRenderer` and * `TextFieldTextRenderer`. * * @see #labelFactory * @see feathers.core.ITextRenderer * @see feathers.core.BitmapFontTextRenderer * @see feathers.core.TextFieldTextRenderer * @see #defaultLabelProperties */ public function get onLabelProperties():Dictionary. { if(!this._onLabelProperties) { this._onLabelProperties = new Dictionary.; } return this._onLabelProperties; } /** * @private */ public function set onLabelProperties(value:Dictionary.):void { this._onLabelProperties = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _offLabelProperties:Dictionary.; /** * A set of key/value pairs to be passed down to the toggle switch's * OFF label text renderer. If `null`, then * `defaultLabelProperties` is used instead. The label text * renderers are `ITextRenderer` instances. The available * properties depend on which `ITextRenderer` implementation * is returned by `labelFactory`. The most common * implementations are `BitmapFontTextRenderer` and * `TextFieldTextRenderer`. * * @see #labelFactory * @see feathers.core.ITextRenderer * @see feathers.core.BitmapFontTextRenderer * @see feathers.core.TextFieldTextRenderer * @see #defaultLabelProperties */ public function get offLabelProperties():Dictionary. { if(!this._offLabelProperties) { this._offLabelProperties = new Dictionary.; } return this._offLabelProperties; } /** * @private */ public function set offLabelProperties(value:Dictionary.):void { this._offLabelProperties = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _labelAlign:String = LABEL_ALIGN_BASELINE; [Inspectable(type=""String"",enumeration=""baseline,middle"")] /** * The vertical alignment of the label. */ public function get labelAlign():String { return this._labelAlign; } /** * @private */ public function set labelAlign(value:String):void { if(this._labelAlign == value) { return; } this._labelAlign = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _labelFactory:Function; /** * A function used to instantiate the toggle switch's label text * renderer sub-components. The label text renderers must be instances * of `ITextRenderer`. This factory can be used to change * properties on the label text renderer when it is first created. For * instance, if you are skinning Feathers components without a theme, * you might use this factory to style the label text renderer. * * The factory should have the following function signature: * `function():ITextRenderer` * * @see feathers.core.ITextRenderer * @see feathers.core.FeathersControl#defaultTextRendererFactory */ public function get labelFactory():Function { return this._labelFactory; } /** * @private */ public function set labelFactory(value:Function):void { if(this._labelFactory == value) { return; } this._labelFactory = value; this.invalidate(INVALIDATION_FLAG_TEXT_RENDERER); } /** * @private */ protected var onTrackSkinOriginalWidth:Number = NaN; /** * @private */ protected var onTrackSkinOriginalHeight:Number = NaN; /** * @private */ protected var offTrackSkinOriginalWidth:Number = NaN; /** * @private */ protected var offTrackSkinOriginalHeight:Number = NaN; /** * @private */ protected var _isSelected:Boolean = false; /** * Indicates if the toggle switch is selected (ON) or not (OFF). */ public function get isSelected():Boolean { return this._isSelected; } /** * @private */ public function set isSelected(value:Boolean):void { //normally, we'd check to see if selected actually changed or not //but the animation is triggered by the draw cycle, so we always //need to invalidate. notice that the event isn't dispatched //unless the value changes. const oldSelected:Boolean = this._isSelected; this._isSelected = value; this._isSelectionChangedByUser = false; this.invalidate(INVALIDATION_FLAG_SELECTED); if(this._isSelected != oldSelected) { this.dispatchEventWith(Event.CHANGE); } } /** * @private */ protected var _toggleDuration:Number = 0.15; /** * The duration, in seconds, of the animation when the toggle switch * is toggled and animates the position of the thumb. */ public function get toggleDuration():Number { return this._toggleDuration; } /** * @private */ public function set toggleDuration(value:Number):void { this._toggleDuration = value; } /** * @private */ protected var _toggleEase:Object = Transitions.EASE_OUT; /** * The easing function used for toggle animations. */ public function get toggleEase():Object { return this._toggleEase; } /** * @private */ public function set toggleEase(value:Object):void { this._toggleEase = value; } /** * @private */ protected var _onText:String = ""ON""; /** * The text to display in the ON label. */ public function get onText():String { return this._onText; } /** * @private */ public function set onText(value:String):void { if(value === null) { value = """"; } if(this._onText == value) { return; } this._onText = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _offText:String = ""OFF""; /** * The text to display in the OFF label. */ public function get offText():String { return this._offText; } /** * @private */ public function set offText(value:String):void { if(value === null) { value = """"; } if(this._offText == value) { return; } this._offText = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _toggleTween:Tween; /** * @private */ protected var _ignoreTapHandler:Boolean = false; /** * @private */ protected var _touchPointID:int = -1; /** * @private */ protected var _thumbStartX:Number; /** * @private */ protected var _touchStartX:Number; /** * @private */ protected var _isSelectionChangedByUser:Boolean = false; /** * @private */ protected var _onTrackFactory:Function; /** * A function used to generate the toggle switch's on track * sub-component. The on track must be an instance of `Button`. * This factory can be used to change properties on the on track when it * is first created. For instance, if you are skinning Feathers * components without a theme, you might use this factory to set skins * and other styles on the on track. * * The function should have the following signature: * `function():Button` * * @see feathers.controls.Button * @see #onTrackProperties */ public function get onTrackFactory():Function { return this._onTrackFactory; } /** * @private */ public function set onTrackFactory(value:Function):void { if(this._onTrackFactory == value) { return; } this._onTrackFactory = value; this.invalidate(INVALIDATION_FLAG_ON_TRACK_FACTORY); } /** * @private */ protected var _customOnTrackName:String; /** * A name to add to the toggle switch's on track sub-component. Typically * used by a theme to provide different skins to different toggle switches. * * @see feathers.core.FeathersControl#nameList * @see #onTrackFactory * @see #onTrackProperties */ public function get customOnTrackName():String { return this._customOnTrackName; } /** * @private */ public function set customOnTrackName(value:String):void { if(this._customOnTrackName == value) { return; } this._customOnTrackName = value; this.invalidate(INVALIDATION_FLAG_ON_TRACK_FACTORY); } /** * @private */ protected var _onTrackProperties:Dictionary.; /** * A set of key/value pairs to be passed down to the toggle switch's on * track sub-component. The on track is a * `feathers.controls.Button` instance. * * If the subcomponent has its own subcomponents, their properties * can be set too, using attribute `@` notation. For example, * to set the skin on the thumb of a `SimpleScrollBar` * which is in a `Scroller` which is in a `List`, * you can use the following syntax: * `list.scrollerProperties.@verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);` * * Setting properties in a `onTrackFactory` function * instead of using `onTrackProperties` will result in * better performance. * * @see feathers.controls.Button * @see #onTrackFactory */ public function get onTrackProperties():Dictionary. { if(!this._onTrackProperties) { this._onTrackProperties = new Dictionary.; } return this._onTrackProperties; } /** * @private */ public function set onTrackProperties(value:Dictionary.):void { if(this._onTrackProperties == value) { return; } this._onTrackProperties = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _offTrackFactory:Function; /** * A function used to generate the toggle switch's off track * sub-component. The off track must be an instance of `Button`. * This factory can be used to change properties on the off track when it * is first created. For instance, if you are skinning Feathers * components without a theme, you might use this factory to set skins * and other styles on the off track. * * The function should have the following signature: * `function():Button` * * @see feathers.controls.Button * @see #offTrackProperties */ public function get offTrackFactory():Function { return this._offTrackFactory; } /** * @private */ public function set offTrackFactory(value:Function):void { if(this._offTrackFactory == value) { return; } this._offTrackFactory = value; this.invalidate(INVALIDATION_FLAG_OFF_TRACK_FACTORY); } /** * @private */ protected var _customOffTrackName:String; /** * A name to add to the toggle switch's off track sub-component. Typically * used by a theme to provide different skins to different toggle switches. * * @see feathers.core.FeathersControl#nameList * @see #offTrackFactory * @see #offTrackProperties */ public function get customOffTrackName():String { return this._customOffTrackName; } /** * @private */ public function set customOffTrackName(value:String):void { if(this._customOffTrackName == value) { return; } this._customOffTrackName = value; this.invalidate(INVALIDATION_FLAG_OFF_TRACK_FACTORY); } /** * @private */ protected var _offTrackProperties:Dictionary.; /** * A set of key/value pairs to be passed down to the toggle switch's off * track sub-component. The off track is a * `feathers.controls.Button` instance. * * If the subcomponent has its own subcomponents, their properties * can be set too, using attribute `@` notation. For example, * to set the skin on the thumb of a `SimpleScrollBar` * which is in a `Scroller` which is in a `List`, * you can use the following syntax: * `list.scrollerProperties.@verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);` * * Setting properties in a `offTrackFactory` function * instead of using `offTrackProperties` will result in * better performance. * * @see feathers.controls.Button * @see #offTrackFactory */ public function get offTrackProperties():Dictionary. { if(!this._offTrackProperties) { this._offTrackProperties = new Dictionary.; } return this._offTrackProperties; } /** * @private */ public function set offTrackProperties(value:Dictionary.):void { if(this._offTrackProperties == value) { return; } this._offTrackProperties = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected var _thumbFactory:Function; /** * A function used to generate the toggle switch's thumb sub-component. * This can be used to change properties on the thumb when it is first * created. For instance, if you are skinning Feathers components * without a theme, you might use `thumbFactory` to set * skins and text styles on the thumb. * * The function should have the following signature: * `function():Button` * * @see #thumbProperties */ public function get thumbFactory():Function { return this._thumbFactory; } /** * @private */ public function set thumbFactory(value:Function):void { if(this._thumbFactory == value) { return; } this._thumbFactory = value; this.invalidate(INVALIDATION_FLAG_THUMB_FACTORY); } /** * @private */ protected var _customThumbName:String; /** * A name to add to the toggle switch's thumb sub-component. Typically * used by a theme to provide different skins to different toggle switches. * * @see feathers.core.FeathersControl#nameList * @see #thumbFactory * @see #thumbProperties */ public function get customThumbName():String { return this._customThumbName; } /** * @private */ public function set customThumbName(value:String):void { if(this._customThumbName == value) { return; } this._customThumbName = value; this.invalidate(INVALIDATION_FLAG_THUMB_FACTORY); } /** * @private */ protected var _thumbProperties:Dictionary.; /** * A set of key/value pairs to be passed down to the toggle switch's * thumb sub-component. The thumb is a * `feathers.controls.Button` instance. * * If the subcomponent has its own subcomponents, their properties * can be set too, using attribute `@` notation. For example, * to set the skin on the thumb of a `SimpleScrollBar` * which is in a `Scroller` which is in a `List`, * you can use the following syntax: * `list.scrollerProperties.@verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);` * * Setting properties in a `thumbFactory` function instead * of using `thumbProperties` will result in better * performance. * * @see feathers.controls.Button * @see #thumbFactory */ public function get thumbProperties():Dictionary. { if(!this._thumbProperties) { this._thumbProperties = new Dictionary.; } return this._thumbProperties; } /** * @private */ public function set thumbProperties(value:Dictionary.):void { if(this._thumbProperties == value) { return; } this._thumbProperties = value; this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ override protected function draw():void { const selectionInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_SELECTED); const stylesInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_STYLES); var sizeInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_SIZE); const stateInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_STATE); const focusInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_FOCUS); const textRendererInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_TEXT_RENDERER); const thumbFactoryInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_THUMB_FACTORY); const onTrackFactoryInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_ON_TRACK_FACTORY); const offTrackFactoryInvalid:Boolean = this.isInvalid(INVALIDATION_FLAG_OFF_TRACK_FACTORY); if(thumbFactoryInvalid) { this.createThumb(); } if(onTrackFactoryInvalid) { this.createOnTrack(); } this.createOrDestroyOffTrackIfNeeded(offTrackFactoryInvalid); if(textRendererInvalid) { this.createLabels(); } if(stylesInvalid) { this.refreshOnLabelStyles(); this.refreshOffLabelStyles(); } if(thumbFactoryInvalid || stylesInvalid) { this.refreshThumbStyles(); } if(onTrackFactoryInvalid || stylesInvalid) { this.refreshOnTrackStyles(); } if((offTrackFactoryInvalid || stylesInvalid) && this.offTrack) { this.refreshOffTrackStyles(); } if(thumbFactoryInvalid || stateInvalid) { this.thumb.isEnabled = this._isEnabled; } if(onTrackFactoryInvalid || stateInvalid) { this.onTrack.isEnabled = this._isEnabled; } if((offTrackFactoryInvalid || stateInvalid) && this.offTrack) { this.offTrack.isEnabled = this._isEnabled; } sizeInvalid = this.autoSizeIfNeeded() || sizeInvalid; if(sizeInvalid || stylesInvalid || selectionInvalid) { this.updateSelection(); } if(stylesInvalid || sizeInvalid || stateInvalid || selectionInvalid) { this.layoutChildren(); } if(sizeInvalid || focusInvalid) { this.refreshFocusIndicator(); } } /** * @private */ protected function autoSizeIfNeeded():Boolean { if(isNaN(this.onTrackSkinOriginalWidth) || isNaN(this.onTrackSkinOriginalHeight)) { this.onTrack.validate(); this.onTrackSkinOriginalWidth = this.onTrack.width; this.onTrackSkinOriginalHeight = this.onTrack.height; } if(this.offTrack) { if(isNaN(this.offTrackSkinOriginalWidth) || isNaN(this.offTrackSkinOriginalHeight)) { this.offTrack.validate(); this.offTrackSkinOriginalWidth = this.offTrack.width; this.offTrackSkinOriginalHeight = this.offTrack.height; } } const needsWidth:Boolean = isNaN(this.explicitWidth); const needsHeight:Boolean = isNaN(this.explicitHeight); if(!needsWidth && !needsHeight) { return false; } this.thumb.validate(); var newWidth:Number = this.explicitWidth; var newHeight:Number = this.explicitHeight; if(needsWidth) { if(this.offTrack) { newWidth = Math.min(this.onTrackSkinOriginalWidth, this.offTrackSkinOriginalWidth) + this.thumb.width / 2; } else { newWidth = this.onTrackSkinOriginalWidth; } } if(needsHeight) { if(this.offTrack) { newHeight = Math.max(this.onTrackSkinOriginalHeight, this.offTrackSkinOriginalHeight); } else { newHeight = this.onTrackSkinOriginalHeight; } } return this.setSizeInternal(newWidth, newHeight, false); } /** * @private */ protected function createThumb():void { if(this.thumb) { this.thumb.removeFromParent(true); this.thumb = null; } const factory:Function = this._thumbFactory != null ? this._thumbFactory : defaultThumbFactory; const thumbName:String = this._customThumbName != null ? this._customThumbName : this.thumbName; this.thumb = Button(factory.call()); this.thumb.nameList.add(thumbName); this.thumb.keepDownStateOnRollOut = true; this.thumb.addEventListener(TouchEvent.TOUCH, thumb_touchHandler); this.addChild(this.thumb); } /** * @private */ protected function createOnTrack():void { if(this.onTrack) { this.onTrack.removeFromParent(true); this.onTrack = null; } const factory:Function = this._onTrackFactory != null ? this._onTrackFactory : defaultOnTrackFactory; const onTrackName:String = this._customOnTrackName != null ? this._customOnTrackName : this.onTrackName; this.onTrack = Button(factory.call()); this.onTrack.nameList.add(onTrackName); this.onTrack.keepDownStateOnRollOut = true; this.addChildAt(this.onTrack, 0); } /** * @private */ protected function createOrDestroyOffTrackIfNeeded(offTrackFactoryInvalid:Boolean):void { if(this._trackLayoutMode == TRACK_LAYOUT_MODE_ON_OFF) { if(!offTrackFactoryInvalid) { return; } if(this.offTrack) { this.offTrack.removeFromParent(true); this.offTrack = null; } const factory:Function = this._offTrackFactory != null ? this._offTrackFactory : defaultOffTrackFactory; const offTrackName:String = this._customOffTrackName != null ? this._customOffTrackName : this.offTrackName; this.offTrack = Button(factory.call()); this.offTrack.nameList.add(offTrackName); this.offTrack.keepDownStateOnRollOut = true; this.addChildAt(this.offTrack, 1); } else if(this.offTrack) //single { this.offTrack.removeFromParent(true); this.offTrack = null; } } /** * @private */ protected function createLabels():void { if(this.offTextRenderer) { this.removeChild(DisplayObject(this.offTextRenderer), true); this.offTextRenderer = null; } if(this.onTextRenderer) { this.removeChild(DisplayObject(this.onTextRenderer), true); this.onTextRenderer = null; } const index:int = this.getChildIndex(this.thumb); const factory:Function = this._labelFactory != null ? this._labelFactory : FeathersControl.defaultTextRendererFactory; this.offTextRenderer = ITextRenderer(factory.call()); this.offTextRenderer.nameList.add(this.offLabelName); if(this.offTextRenderer is FeathersControl) { FeathersControl(this.offTextRenderer).clipRect = new Rectangle(); } this.addChildAt(DisplayObject(this.offTextRenderer), index); this.onTextRenderer = ITextRenderer(factory.call()); this.onTextRenderer.nameList.add(this.onLabelName); if(this.onTextRenderer is FeathersControl) { FeathersControl(this.onTextRenderer).clipRect = new Rectangle(); } this.addChildAt(DisplayObject(this.onTextRenderer), index); } /** * @private */ protected function layoutChildren():void { this.thumb.validate(); this.thumb.y = (this.actualHeight - this.thumb.height) / 2; const maxLabelWidth:Number = Math.max(0, this.actualWidth - this.thumb.width - this._paddingLeft - this._paddingRight); var totalLabelHeight:Number = Math.max(this.onTextRenderer.height, this.offTextRenderer.height); var labelHeight:Number; if(this._labelAlign == LABEL_ALIGN_MIDDLE) { labelHeight = totalLabelHeight; } else //baseline { labelHeight = Math.max(this.onTextRenderer.baseline, this.offTextRenderer.baseline); } if(this.onTextRenderer is FeathersControl) { var clipRect:Rectangle = FeathersControl(this.onTextRenderer).clipRect; clipRect.width = maxLabelWidth; clipRect.height = totalLabelHeight; FeathersControl(this.onTextRenderer).clipRect = clipRect; } this.onTextRenderer.y = (this.actualHeight - labelHeight) / 2; if(this.offTextRenderer is FeathersControl) { clipRect = FeathersControl(this.offTextRenderer).clipRect; clipRect.width = maxLabelWidth; clipRect.height = totalLabelHeight; FeathersControl(this.offTextRenderer).clipRect = clipRect; } this.offTextRenderer.y = (this.actualHeight - labelHeight) / 2; this.layoutTracks(); } /** * @private */ protected function layoutTracks():void { const maxLabelWidth:Number = Math.max(0, this.actualWidth - this.thumb.width - this._paddingLeft - this._paddingRight); const thumbOffset:Number = this.thumb.x - this._paddingLeft; var onScrollOffset:Number = maxLabelWidth - thumbOffset - (maxLabelWidth - this.onTextRenderer.width) / 2; if(this.onTextRenderer is FeathersControl) { const displayOnLabelRenderer:FeathersControl = FeathersControl(this.onTextRenderer); var currentClipRect:Rectangle = displayOnLabelRenderer.clipRect; currentClipRect.x = onScrollOffset displayOnLabelRenderer.clipRect = currentClipRect; } this.onTextRenderer.x = this._paddingLeft - onScrollOffset; var offScrollOffset:Number = -thumbOffset - (maxLabelWidth - this.offTextRenderer.width) / 2; if(this.offTextRenderer is FeathersControl) { const displayOffLabelRenderer:FeathersControl = FeathersControl(this.offTextRenderer); currentClipRect = displayOffLabelRenderer.clipRect; currentClipRect.x = offScrollOffset displayOffLabelRenderer.clipRect = currentClipRect; } this.offTextRenderer.x = this.actualWidth - this._paddingRight - maxLabelWidth - offScrollOffset; if(this._trackLayoutMode == TRACK_LAYOUT_MODE_ON_OFF) { this.layoutTrackWithOnOff(); } else { this.layoutTrackWithSingle(); } } /** * @private */ protected function updateSelection():void { this.thumb.validate(); var xPosition:Number = this._paddingLeft; if(this._isSelected) { xPosition = this.actualWidth - this.thumb.width - this._paddingRight; } //stop the tween, no matter what if(this._toggleTween) { Loom2D.juggler.remove(this._toggleTween); this._toggleTween = null; } if(this._isSelectionChangedByUser) { this._toggleTween = new Tween(this.thumb, this._toggleDuration, this._toggleEase); this._toggleTween.animate(""x"", xPosition); this._toggleTween.onUpdate = selectionTween_onUpdate; this._toggleTween.onComplete = selectionTween_onComplete; Loom2D.juggler.add(this._toggleTween); } else { this.thumb.x = xPosition; } this._isSelectionChangedByUser = false; } /** * @private */ protected function refreshOnLabelStyles():void { //no need to style the label field if there's no text to display if(!this._showLabels || !this._showThumb) { this.onTextRenderer.visible = false; return; } var properties:PropertyProxy; if(!this._isEnabled) { properties = this._disabledLabelProperties; } if(!properties && this._onLabelProperties) { properties = this._onLabelProperties; } if(!properties) { properties = this._defaultLabelProperties; } this.onTextRenderer.text = this._onText; if(properties) { Dictionary.mapToObject(properties, onTextRenderer); } this.onTextRenderer.validate(); this.onTextRenderer.visible = true; } /** * @private */ protected function refreshOffLabelStyles():void { //no need to style the label field if there's no text to display if(!this._showLabels || !this._showThumb) { this.offTextRenderer.visible = false; return; } var properties:PropertyProxy; if(!this._isEnabled) { properties = this._disabledLabelProperties; } if(!properties && this._offLabelProperties) { properties = this._offLabelProperties; } if(!properties) { properties = this._defaultLabelProperties; } this.offTextRenderer.text = this._offText; if(properties) { Dictionary.mapToObject(properties, onTextRenderer); } this.offTextRenderer.validate(); this.offTextRenderer.visible = true; } /** * @private */ protected function refreshThumbStyles():void { Dictionary.mapToObject(_thumbProperties, thumb); this.thumb.visible = this._showThumb; } /** * @private */ protected function refreshOnTrackStyles():void { Dictionary.mapToObject(_onTrackProperties, onTrack); } /** * @private */ protected function refreshOffTrackStyles():void { if(!this.offTrack) { return; } Dictionary.mapToObject(_offTrackProperties, offTrack); } /** * @private */ protected function layoutTrackWithOnOff():void { this.onTrack.x = 0; this.onTrack.y = 0; this.onTrack.width = this.thumb.x + this.thumb.width / 2; this.onTrack.height = this.actualHeight; this.offTrack.x = this.onTrack.width; this.offTrack.y = 0; this.offTrack.width = this.actualWidth - this.offTrack.x; this.offTrack.height = this.actualHeight; } /** * @private */ protected function layoutTrackWithSingle():void { this.onTrack.x = 0; this.onTrack.y = 0; this.onTrack.width = this.actualWidth; this.onTrack.height = this.actualHeight; } /** * @private */ protected function childProperties_onChange(proxy:PropertyProxy, name:Object):void { this.invalidate(INVALIDATION_FLAG_STYLES); } /** * @private */ protected function toggleSwitch_removedFromStageHandler(event:Event):void { this._touchPointID = -1; } /** * @private */ override protected function focusInHandler(event:Event):void { super.focusInHandler(event); this.stage.addEventListener(KeyboardEvent.KEY_DOWN, stage_keyDownHandler); this.stage.addEventListener(KeyboardEvent.KEY_UP, stage_keyUpHandler); } /** * @private */ override protected function focusOutHandler(event:Event):void { super.focusOutHandler(event); this.stage.removeEventListener(KeyboardEvent.KEY_DOWN, stage_keyDownHandler); this.stage.removeEventListener(KeyboardEvent.KEY_UP, stage_keyUpHandler); } /** * @private */ protected function toggleSwitch_touchHandler(event:TouchEvent):void { if(this._ignoreTapHandler) { this._ignoreTapHandler = false; return; } if(!this._isEnabled) { this._touchPointID = -1; return; } const touches:Vector. = event.getTouches(this, null, HELPER_TOUCHES_VECTOR); if(touches.length == 0) { return; } var touch:Touch; for each(var currentTouch:Touch in touches) { if((this._touchPointID >= 0 && currentTouch.id == this._touchPointID) || (this._touchPointID < 0 && currentTouch.phase == TouchPhase.ENDED)) { touch = currentTouch; break; } } if(!touch || touch.phase != TouchPhase.ENDED) { HELPER_TOUCHES_VECTOR.length = 0; return; } this._touchPointID = -1; touch.getLocation(this.stage, HELPER_POINT); if(this.contains(this.stage.hitTest(HELPER_POINT, true))) { this.isSelected = !this._isSelected; this._isSelectionChangedByUser = true; } HELPER_TOUCHES_VECTOR.length = 0; } /** * @private */ protected function thumb_touchHandler(event:TouchEvent):void { if(!this._isEnabled) { return; } const touches:Vector. = event.getTouches(this.thumb, null, HELPER_TOUCHES_VECTOR); if(touches.length == 0) { return; } if(this._touchPointID >= 0) { var touch:Touch; for each(var currentTouch:Touch in touches) { if(currentTouch.id == this._touchPointID) { touch = currentTouch; break; } } if(!touch) { HELPER_TOUCHES_VECTOR.length = 0; return; } touch.getLocation(this, HELPER_POINT); const trackScrollableWidth:Number = this.actualWidth - this._paddingLeft - this._paddingRight - this.thumb.width; if(touch.phase == TouchPhase.MOVED) { const xOffset:Number = HELPER_POINT.x - this._touchStartX; const xPosition:Number = Math.min(Math.max(this._paddingLeft, this._thumbStartX + xOffset), this._paddingLeft + trackScrollableWidth); this.thumb.x = xPosition; this.layoutTracks(); } else if(touch.phase == TouchPhase.ENDED) { const inchesMoved:Number = Math.abs(HELPER_POINT.x - this._touchStartX) / DeviceCapabilities.dpi; if(inchesMoved > MINIMUM_DRAG_DISTANCE) { this._touchPointID = -1; this.isSelected = this.thumb.x > (this._paddingLeft + trackScrollableWidth / 2); this._isSelectionChangedByUser = true; this._ignoreTapHandler = true; } } } else { for each(touch in touches) { if(touch.phase == TouchPhase.BEGAN) { touch.getLocation(this, HELPER_POINT); this._touchPointID = touch.id; this._thumbStartX = this.thumb.x; this._touchStartX = HELPER_POINT.x; break; } } } HELPER_TOUCHES_VECTOR.length = 0; } /** * @private */ protected function stage_keyDownHandler(event:KeyboardEvent):void { if(event.keyCode == Keyboard.ESCAPE) { this._touchPointID = -1; } if(this._touchPointID >= 0 || event.keyCode != Keyboard.SPACE) { return; } this._touchPointID = int.MAX_VALUE; } /** * @private */ protected function stage_keyUpHandler(event:KeyboardEvent):void { if(this._touchPointID != int.MAX_VALUE || event.keyCode != Keyboard.SPACE) { return; } this._touchPointID = -1; this.isSelected = !this._isSelected; } /** * @private */ protected function selectionTween_onUpdate():void { this.layoutTracks(); } /** * @private */ protected function selectionTween_onComplete():void { this._toggleTween = null; } } }",12092,False,2478.325086975296,median "/* * DESCRIPTION * * This device can toggle two relays, and thus two electric locks. These relays can be controlled via the Candle Controller, but also via SMS (if you want). * The SMS function is password protected: you have to send a password to switch the relay. Access can also be limited to only certain mobile phone numbers, and only certain moments (by toggling the Mobile control switch). * * If you send an SMS without the password, it will be shown as the Incoming SMS. This can be used to automate other things in your home. For example, you could create a rule that when the system receices an SMS with ""purifier on"" in it, the air purifier will turn on. * * This way you can control smart devices in your home even if it/Candle is not connected to the internet. * * If data transmission is disabled, you can change the state of the lock via SMS or the pushbutton without the new state being sent to the controller. * * SETTINGS */ // It's important to change these to your own phone number(s). When the device starts up it will always start with these values. // You will also be able to change this via your controller later, but in case no connection to the controller can be established it's a good idea to enter your phonenumber here. char phone1[15] = ""+031612345678""; // Phone number of user #1. This is the main number to which status updates will be sent. char phone2[15] = ""+031612345678""; // Phone number of user #2 (optional). If there is no second user, set it the same number as user #1. char rotatingPassword1[26] = ""door1""; // Door 1 password. If the device is powered up and can't reconnect to the home network, then this will be the fallback password. Maximum length is 25 characters. #define DOOR1_SELF_LOCKING // Self locking? Should door number one automatically re-lock itself after a short amount of time? char rotatingPassword2[26] = ""door2""; // Door 2 password. If the device is powered up and can't reconnect to the home network, then this will be the fallback password. Maximum length is 25 characters. //#define DOOR2_SELF_LOCKING // Self locking? Should door number two automatically re-lock itself after a short amount of time? #define SELF_LOCKING_DELAY 5 // Self locking delay. If a door is self-locking, how many seconds before it should re-lock? //#define HAS_BUTTONS // Have you attached buttons? You can toggle the state of each lock with a push button if you want. If you want this feature, even if you only want it for one, you have to attach two buttons, one for each door. #define APN_URL ""internet"" // APN Name. The APN URL from your mobile provider. Check your provider website for the precise settings. #define APN_USERNAME """" // APN Login. The APN username from your mobile provider. You can try leaving this and the password empty. #define APN_PASSWORD """" // APN Password. The APN password from your mobile provider. //#define SEND_SMS_EVERY_49_DAYS // Send SMS every 49 days. If you are using a prepaid simcard, you may have to send an SMS once in a while to stop your simcard from getting disabled. This function tries sending an SMS to you once every 49 days. #define ALLOW_CONNECTING_TO_NETWORK // Connect wirelessly. Is this device allowed to connect to the network? For privacy or security reasons you may prefer a stand-alone device. If you do allow the device to connect, you can connect a button to switch the transmission of data or off. #define RF_NANO // RF-Nano. Check this box if you are using the RF-Nano Arduino, which has a built in radio. The Candle project uses the RF-Nano. /* END OF SETTINGS * * * LYCAMOBILE * APN: data.lycamobile.nl * Username: lmnl * Password: plus * CUSD command to get phone number: *102# * * LEBARA * APN: internet * No username or password are required, so they can be empty. * */ //#define DEBUG // Display debug information in the serial output. //#define MY_DEBUG // Enable MySensors debug output to the serial monitor, so you can check if the radio is working ok. //#define JESSE // Enables the special features for Jesse Howard's Candle prototypes. // Enable and select the attached radio type #define MY_RADIO_RF24 // This is a common and simple radio used with MySensors. Downside is that it uses the same frequency space as WiFi. //#define MY_RADIO_NRF5_ESB // This is a new type of device that is arduino and radio all in one. Currently not suitable for beginners yet. //#define MY_RADIO_RFM69 // This is an open source radio on the 433mhz frequency. Great range and built-in encryption, but more expensive and little more difficult to connect. //#define MY_RADIO_RFM95 // This is a LoRaWan radio, which can have a range of 10km. // MySensors: Choose your desired radio power level. High power can cause issues on cheap Chinese NRF24 radio's. //#define MY_RF24_PA_LEVEL RF24_PA_MIN //#define MY_RF24_PA_LEVEL RF24_PA_LOW //#define MY_RF24_PA_LEVEL RF24_PA_HIGH #define MY_RF24_PA_LEVEL RF24_PA_MAX // Mysensors security //#define DEBUG_SIGNING #define MY_ENCRYPTION_SIMPLE_PASSWD ""changeme"" // Be aware, the length of the password has an effect on memory use. //#define MY_SECURITY_SIMPLE_PASSWD ""changeme"" // Be aware, the length of the password has an effect on memory use. //#define MY_SIGNING_SOFT_RANDOMSEED_PIN A7 // Setting a pin to pickup random electromagnetic noise helps make encryption more secure. // Mysensors advanced settings #define MY_TRANSPORT_WAIT_READY_MS 10000 // Try connecting for 10 seconds. Otherwise just continue. //#define MY_RF24_CHANNEL 100 // In EU the default channel 76 overlaps with wifi, so you could try using channel 100. But you will have to set this up on every device, and also on the controller. #define MY_RF24_DATARATE RF24_1MBPS // Slower datarate makes the network more stable //#define MY_RF24_DATARATE RF24_250KBPS // Slower datarate increases wireless range //#define MY_NODE_ID 10 // Giving a node a manual ID can in rare cases fix connection issues. //#define MY_PARENT_NODE_ID 0 // Fixating the ID of the gatewaynode can in rare cases fix connection issues. //#define MY_PARENT_NODE_IS_STATIC // Used together with setting the parent node ID. Daking the controller ID static can in rare cases fix connection issues. #define MY_SPLASH_SCREEN_DISABLED // Saves a little memory. //#define MY_DISABLE_RAM_ROUTING_TABLE_FEATURE // Saves a little memory. // MySensors devices form a mesh network by passing along messages for each other. Do you want this node to also be a repeater? #define MY_REPEATER_FEATURE // Add or remove the two slashes at the beginning of this line to select if you want this sensor to act as a repeater for other sensors. If this node is on battery power, you probably shouldn't enable this. // Define Node ID //#define MY_NODE_ID 15 //#define MY_PARENT_NODE_ID 0 //#define MY_PARENT_NODE_IS_STATIC // PINS #define GSM_RECEIVE_PIN 3 // Connect to U_TXD on the GSM module #define GSM_TRANSMIT_PIN 4 // Connect to U_RXD on the GSM module #define RELAY1_PIN 5 // Relay 1 pin number (use this on a door that needs a short pulse to open). #define RELAY2_PIN 6 // Relay 2 pin number (use this on a door that can be set to locked or unlocked mode, for example with a solenoid.). #ifdef JESSE // For the Candle prototype by Jesse Howard #define TOGGLE_FAKE_DATA_PIN A3 #define TOP_MOTOR_SWITCH_PIN A1 #define BOTTOM_MOTOR_SWITCH_PIN A2 #define MOTOR_FORWARD_PIN 7 #define MOTOR_BACKWARD_PIN 8 #else #define BUTTON1_PIN A0 // Manual momentary button for door 1. #define BUTTON2_PIN A1 // Manual momentary button for door 2. #endif #ifdef RF_NANO // If you are using an RF-Nano, you have to switch CE and CS pins. #define MY_RF24_CS_PIN 9 // Used by the MySensors library. #define MY_RF24_CE_PIN 10 // Used by the MySensors library. #endif // THESE VALUES CAN BE CHANGED #define LOOP_DURATION 1000 // The main loop runs every x milliseconds. This main loop starts the modem, and from then on periodically requests the password. #define SECONDS_BETWEEN_HEARTBEAT_TRANSMISSION 120 // The smart lock might not send any data for a very long time if it isn't used. Sending a heartbeat tells the controller: I'm still there. #define MAXIMUMTIMEOUTS 30 // How often the network may fail before we conclude there is a connection problem. #define LOCKED 1 // This makes it easier to understand what the code is doing. It allows the code to say ""LOCKED"" instead of ""1"". #define UNLOCKED 0 // This makes it easier to understand what the code is doing. It allows the code to say ""UNLOCKED"" instead of ""0"". #define RELAY_LOCKED 1 // Some relays work in reverse. This allows you to choose if a 'lock' signal should send a HIGH or LOW signal to your relay #define RELAY_UNLOCKED 0 // Some relays work in reverse. This allows you to choose if an 'unlock' signal should send a HIGH or LOW signal to your relay. #define EEPROM_STORAGE_START 512 // From which position the eeprom can safely be used as storage without overwriting MySensors encryption data. Another option would be to use EEPROM_LOCAL_CONFIG_ADDRESS, a MySensors feature. // Libraries #include // The MySensors library that allows devices to communicate and form networks. #include #include // Allows for storing data on the Arduino itself, like a mini hard-drive. // Software serial #define _SS_MAX_RX_BUFF 255 // The size of the software serial buffer #define SERIAL_LINE_LENGTH 128 // The maximum length that a line from the GSM modem can be. #include // A software library for serial communication. In this case we use it to talk to the GSM modem. Currently not used because of a strange issue. SoftwareSerial modem(GSM_RECEIVE_PIN,GSM_TRANSMIT_PIN); // Receive pin (RX), transmit pin (TX) char serial_line[SERIAL_LINE_LENGTH]; // Holds the line received from the modem. // MySensors children #define DEVICE_STATUS_ID 0 // The first 'child' of this device is a text field that contains status updates. #define SMS_CHILD_ID 1 // This field is used to tell the controller what text was in the sms. Useful for automation of other things that you want to trigger using an SMS. #define SENDSMS_CHILD_ID 2 // If this string is modified at the controller, a test sms will be sent. Useful to keep a simcard alive (must send at least one SMS every X months usually). #define BUTTON_CHILD_ID 3 // Set button ID number on this node. #define TRANSMISSION_STATE_CHILD_ID 4 // The child ID of the data transmission switch. #define SMS_CONTROL_ID 5 // Toggle whether SMS is allowed to control the lock. #define ROTATING_PASSWORD1_ID 10 // Set password ID number on this node that can be set from outside. #define ROTATING_PASSWORD2_ID 36 // Set password ID number on this node that can be set from outside. #define PHONENUMBER1_ID 120 // If (part of) a phonenumber is given, only phonenumbers that have that part will be allowed to open the lock. E.g. ""+31"" only allows Dutch numbers. ""+3161482375"" would only allow that one number. #define PHONENUMBER2_ID 135 // If (part of) a phonenumber is given, only phonenumbers that have that part will be allowed to open the lock. E.g. ""+31"" only allows Dutch numbers. ""+3161482375"" would only allow that one number. #define RELAY1_CHILD_ID 210 // Set switch ID number on this node. Door 1. #define RELAY2_CHILD_ID 211 // Set switch ID number on this node. Door 2. This needs to be 1 higher than relay 1. MyMessage text_message(DEVICE_STATUS_ID, V_TEXT); // Sets up the message format that we'll be sending to the MySensors gateway later. The first part is the ID of the specific sensor module on this node. The second part tells the gateway what kind of data to expect. MyMessage relay_message(TRANSMISSION_STATE_CHILD_ID, V_STATUS); // A generic boolean state message. MyMessage lock_message(RELAY1_CHILD_ID, V_STATUS); // A message to send the state of locks. Was 'V_LOCK_STATUS', but this is a currently a read-only property. // General variables #define DOOR_COUNT 2 // How many electric locks are attached. #define RADIO_DELAY 100 // Milliseconds delay betweeen radio signals. This gives the radio some breathing room. boolean incomingSMS = 0; // Used in flow control when processing an SMS. boolean waitingForResponse = false; // Used to check if the connection to the controller is ok. If we are still waiting by the next time a password is requested, something is fishy. boolean send_all_values = 1; boolean processing_line = 0; boolean desired_door_states[DOOR_COUNT]; // An array that holds the desired door states. These are turned into: boolean actualDoorStates[DOOR_COUNT]; // An array that holds the actual door states. const char unlockedMessage[] PROGMEM = { "" unlocked"" }; // This construction saves some memory. Only the first character has to be changed to create a message to send via SMS, such as ""1 locked"" or ""2 unlocked"".s const char lockedMessage[] PROGMEM = { "" locked"" }; // This construction saves some memory. const char passwordMessage[] PROGMEM = { ""Door password"" }; // This construction saves some memory. #define WORK_STRING_SIZE 26 // Length of an array that holds various strings. char work_string[WORK_STRING_SIZE]; // Creates an array that will hold various strings. // MODEM STATES #define MODEM_BUFFER_EMPTY 0 // These three states are used to avoid sending the modem commands while it's still sending them to the Arduino. #define WAITING_FOR_RESPONSE_FROM_MODEM 1 #define MODEM_PROCESSING_RESPONSE 2 byte modem_state = MODEM_BUFFER_EMPTY; boolean modem_booted = false; // DATA TRANSMISSION TOGGLE boolean transmission_state = true; boolean desired_transmission_state = true; boolean sms_control_state = true; boolean desired_sms_control_state = true; boolean store_to_eeprom = false; boolean send_sms = false; #ifdef DEBUG // A small funtion that can tell you how much ram is left. int freeRam () { extern int __heap_start, *__brkval; int v; return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); } // via https://playground.arduino.cc/Code/AvailableMemory #endif // The before function is run very early on. This makes it great for quickly changing pin settings. void before() { Serial.begin(115200); Serial.println(F(""Hello world, I am a door lock."")); memset(desired_door_states,0,sizeof(desired_door_states)); memset(actualDoorStates,0,sizeof(actualDoorStates)); for( byte checkingDoor = 0; checkingDoor < DOOR_COUNT; checkingDoor++ ){ //Serial.print(F(""BUTTON1_PIN + checkingDoor = "")); Serial.println(BUTTON1_PIN + checkingDoor); pinMode(RELAY1_PIN + checkingDoor, OUTPUT); // Set all relay pins to be output. // Set the button pins as input. //pinMode(BUTTON1_PIN + checkingDoor, INPUT); // Set the button pins as input. byte possibleDesiredState = EEPROM.read(EEPROM_STORAGE_START + RELAY1_CHILD_ID + checkingDoor); if( possibleDesiredState == 0 || possibleDesiredState == 1 ){ // If the eeprom has the number '255' here, then it clearly hasn't been set to hold a desired value before, and we should not use it. //Serial.println(""Found useable state in eeprom""); desired_door_states[checkingDoor] = possibleDesiredState; if( possibleDesiredState == LOCKED){ // This may seem complicated. The numerical state that represents 'locked' in the interface could be different from what the relay conciders locked. For example, 1 could be locked in the interface, but unlocked for the relay. And vice-versa. This construction deals with that possibility. digitalWrite(RELAY1_PIN + checkingDoor, RELAY_LOCKED); } if( possibleDesiredState == UNLOCKED){ digitalWrite(RELAY1_PIN + checkingDoor, RELAY_UNLOCKED); } actualDoorStates[checkingDoor] = desired_door_states[checkingDoor]; } else { #ifdef DEBUG Serial.println(F(""No useable state found in eeprom"")); #endif digitalWrite(RELAY1_PIN + checkingDoor, RELAY_UNLOCKED); // If no value was stored in the eeprom, start unlocked, for safety. } } if( EEPROM.read(EEPROM_STORAGE_START + 255) == 1 ){ // This position indicates whether any passwords and phone numbers have been stored in eeprom. Serial.println(F(""Loading phone numbers and passwords from internal memory"")); loadEverythingFromEeprom(); } else{ Serial.println(F(""No preferences stored in internal memory yet"")); } } #ifdef ALLOW_CONNECTING_TO_NETWORK void presentation() { sendSketchInfo(F(""Smart lock""), F(""2.0"")); wait(RADIO_DELAY); present(DEVICE_STATUS_ID, S_INFO, F(""Status"")); wait(RADIO_DELAY); present(SMS_CHILD_ID, S_INFO, F(""Received SMS"")); wait(RADIO_DELAY); present(SENDSMS_CHILD_ID, S_INFO, F(""Send SMS"")); wait(RADIO_DELAY); present(PHONENUMBER1_ID, S_INFO, F(""Phone number 1"")); wait(RADIO_DELAY); present(PHONENUMBER2_ID, S_INFO, F(""Phone number 2"")); wait(RADIO_DELAY); // Presenting the password fields. This is currently over coplicated, but was an experiment in making the code more flexible so it could handle a lot of locks. for( byte i = 0; i < DOOR_COUNT; i++ ){ // We loop over all the doorlocks in the system, and check if they are in the right position. memset(work_string,0,sizeof(work_string)); strcpy_P(work_string, passwordMessage); // This copies the password message that we stored in progmem (flash memory) into real memory. work_string[5] = i + 49; // This will create ""Door 1 password"", ""Door 2 password"", etc. In that string the number is the 5th character (starting form 0). Ascii character 49 = ""1"", character 50 = ""2"", etc. //Serial.println(work_string); present(ROTATING_PASSWORD1_ID + (i*26), S_INFO, work_string); wait(RADIO_DELAY); work_string[6] = '\\0'; // Shortens the string to just be ""Door 1"", ""Door 2"", etc. //Serial.println(work_string); present(RELAY1_CHILD_ID + i, S_BINARY, work_string, true); wait(RADIO_DELAY); } present(TRANSMISSION_STATE_CHILD_ID, S_BINARY, F(""Data transmission"")); wait(RADIO_DELAY); present(SMS_CONTROL_ID, S_BINARY, F(""Mobile control"")); wait(RADIO_DELAY); send_all_values = true; // Whenever a new presentation is requested, we should also send the current values of the children. } void send_values() { #ifdef DEBUG Serial.println(F(""Sending button states"")); #endif send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""OK"")),1); wait(RADIO_DELAY); send(text_message.setSensor(SMS_CHILD_ID).set( F(""""))); wait(RADIO_DELAY); send(text_message.setSensor(SENDSMS_CHILD_ID).set( F(""Change me to send SMS""))); wait(RADIO_DELAY); send(text_message.setSensor(PHONENUMBER1_ID).set( phone1 ),1); wait(RADIO_DELAY); send(text_message.setSensor(PHONENUMBER2_ID).set( phone2 ),1); wait(RADIO_DELAY); #ifdef DEBUG Serial.print(F(""Sending phone1: "")); Serial.println( phone1 ); #endif //for( byte i = 0; i < DOOR_COUNT; i++ ){ //send(text_message.setSensor(ROTATING_PASSWORD1_ID + i).set( F(""change_me"") )); wait(RADIO_DELAY); //} send(text_message.setSensor(ROTATING_PASSWORD1_ID).set( rotatingPassword1 )); wait(RADIO_DELAY); send(text_message.setSensor(ROTATING_PASSWORD2_ID).set( rotatingPassword2 )); wait(RADIO_DELAY); send(relay_message.setSensor(TRANSMISSION_STATE_CHILD_ID).set(transmission_state),1); wait(RADIO_DELAY); send(relay_message.setSensor(SMS_CONTROL_ID).set(sms_control_state),1); wait(RADIO_DELAY); if( transmission_state ){ // Send the state of the locks (if data transmission is allowed) for( byte i = 0; i < DOOR_COUNT; i++ ){ send(lock_message.setSensor(RELAY1_CHILD_ID + i).set( actualDoorStates[i] )); wait(RADIO_DELAY); } } } #endif // connecting to network void setup() { wait(1000); #ifndef JESSE pinMode(BUTTON1_PIN, INPUT_PULLUP); pinMode(BUTTON2_PIN, INPUT_PULLUP); #endif #ifdef ALLOW_CONNECTING_TO_NETWORK #ifdef JESSE pinMode(MOTOR_FORWARD_PIN, OUTPUT); pinMode(MOTOR_BACKWARD_PIN, OUTPUT); pinMode(TOP_MOTOR_SWITCH_PIN, INPUT_PULLUP); pinMode(BOTTOM_MOTOR_SWITCH_PIN, INPUT_PULLUP); transmission_state = digitalRead(TOP_MOTOR_SWITCH_PIN); // Sets the intial state of the motorized toggle switch. #else transmission_state = loadState(TRANSMISSION_STATE_CHILD_ID); #endif Serial.print(F(""Initial transmission state: "")); Serial.println(transmission_state); // Has a connection to the controller been established? if( isTransportReady() ){ Serial.println(F(""Connected to gateway"")); send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""STARTING GSM""))); wait(RADIO_DELAY); }else{ Serial.println(F(""Not connected to gateway"")); //timeOutCount = MAXIMUMTIMEOUTS; // Start the system in 'no connection' mode, meaning the backup passwords may be used. } #endif // allow connecting to network #ifdef DEBUG for ( int i = EEPROM_STORAGE_START; i < EEPROM_STORAGE_START + 512; i++ ){ //char k = EEPROM.read(i); //Serial.print(i); Serial.print(F(""="")); Serial.write(k); Serial.print(F("" ("")); Serial.println( (byte) k); } #endif Serial.println(F(""Connecting to GSM.."")); modem.begin(57600); //57600 // The modem automatically adapts to work at the same baud rate when we send a few commands. modem.println(F(""AT"")); wait(300); modem.println(F(""AT"")); wait(300); modem.println(F(""AT"")); wait(300); modem.println(F(""AT&F"")); // Reset the GSM modem. wait(15000); // After a reset, the GSM modem needs some time to settle. while( modem.available() > 0 ){ // Empty the buffer before we start the actual bootup procedure modem.read(); } wdt_enable(WDTO_8S); // Starts the watchdog timer. If it is not reset once every few seconds, then the entire device will automatically restart. } void loop() { static unsigned long last_loop_time = 0; // Holds the last time the main loop ran. static bool buttonBeingPressed = 0; // Used to debounce the push buttons. static byte number_of_bytes_received = 0; // How many characters we've stored in the serial_line character array. static byte loop_counter = 0; // Count how many loops have passed (reset to 0 after at most 254 loops). static byte modem_counter = 0; //wdt_reset(); // Reset the watchdog timer #ifdef ALLOW_CONNECTING_TO_NETWORK // If a presentation is requested, we also send the values of the children. if( send_all_values ){ #ifdef DEBUG Serial.println(F(""RESENDING VALUES"")); #endif send_all_values = 0; send_values(); } // User initiated a transmission state change remotely if( desired_transmission_state != transmission_state ){ Serial.print(F(""Desired transmission state has changed to "")); Serial.println(desired_transmission_state); #ifdef JESSE transmission_state = motor_switch(desired_transmission_state); #else transmission_state = desired_transmission_state; #endif EEPROM.update(EEPROM_STORAGE_START + TRANSMISSION_STATE_CHILD_ID,transmission_state); // Remember the prefered state in the eeprom memory. This will make sure it is remembered after a reboot. Serial.print(F(""Sending new transmission state: "")); Serial.println(transmission_state); //controller_got_transmission_state = false; if( transmission_state ){ send_values(); // If data transmissin is re-enabled, all current values (including the real state of the locks) are sent to the controller. } else { send(relay_message.setSensor(TRANSMISSION_STATE_CHILD_ID).set(transmission_state),1); wait(RADIO_DELAY); // We acknowledge to the controller that we are now in the new state. } } // User initiated a SMS control change remotely if( desired_sms_control_state != sms_control_state ){ Serial.print(F(""Desired sms control state has changed to "")); Serial.println(desired_sms_control_state); sms_control_state = desired_sms_control_state; Serial.print(F(""Sending new sms control state: "")); Serial.println(sms_control_state); //controller_got_transmission_state = false; send(relay_message.setSensor(SMS_CONTROL_ID).set(sms_control_state),1); wait(RADIO_DELAY);// We acknowledge to the controller that we are now in the new state. wait(RADIO_DELAY); } if( send_sms ){ //Serial.print(F(""controller: send sms. Work_string: "")); Serial.println(work_string); send_sms = false; // Indicates the sms has been sent. sendSMS(); } // If any of the passwords or phone numbers have been updated, they should be stored/updated in eeprom. if( store_to_eeprom ){ store_to_eeprom = false; // Indicates the storage cycle is done. storeEverythingToEeprom(); send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""New value stored""))); wait(RADIO_DELAY); } #endif // connecting to network // // KEEP SIM CARD ALIVE // #ifdef SEND_SMS_EVERY_49_DAYS // This is an optional feature. // Every 49,7 days (using the millis() rollover) the system sends out an SMS. This helps keep the simcard active and registered on the GSM network. // Use at your own risk: if the system experiences a power loss, the timer starts at 0 again. If your experience frequent powerlosses, then the simcard might be-deregistered anyway, since the keep-alive SMS's won't get sent. // A slight delay is built in: the first sms is sent a week after the smart lock becomes active. This avoid sending a lot of SMS's if you are still playing with setting up the device, and powerlosses may be frequent. // This smart lock also offers another option. You can let the controller trigger the sending of the sms using the 'send test sms' button. Of course, your controller could also be down when you scheduled to trigger the button. static bool keepAliveSMSsent = false; // Used to make sure an SMS is only sent as the milliseconds starts, and not during every loop in the millisecond. if(millis() < 5){ keepAliveSMSsent = false; // When the clock rolls over, set the variable back so that a new SMS can be sent. } if (millis() > 604800000 && millis() < 604800010 && keepAliveSMSsent == false){ // 604800000 = 1 week in milliseconds. Sending the first keep-alive SMS after a week avoids sending a lot of SMS-es while testing the system (which may involve a lot of reboots). keepAliveSMSsent = true; strcpy(work_string, phone1); sendSMS(); // If the work string only contains a phone number - as is the case here - a generic ""Hello from Candle"" SMS will be sent. } #endif // // GSM BOOTUP SEQUENCE // if( modem_state == MODEM_BUFFER_EMPTY && modem_booted == false ){ // The receive buffer has been processed. Time to send a new command in the list, or just go into ""ready"" state. modem_counter++; modem_state = WAITING_FOR_RESPONSE_FROM_MODEM; Serial.println(); Serial.print(F(""__GSM boot step "")); Serial.println(modem_counter); #ifdef ALLOW_CONNECTING_TO_NETWORK send(text_message.setSensor(DEVICE_STATUS_ID).set( (char) modem_counter )); wait(RADIO_DELAY); #endif switch( modem_counter ){ case 0: modem.println(F(""AT"")); // Never called, since the modem_counter jumps from 0 to 1 just before this. break; case 1: modem.println(F(""AT+CCID"")); // Initiating the GSM modem //Serial.println(F(""< LOOP_DURATION ){ // Runs every second last_loop_time = millis(); wdt_reset(); // Reset the watchdog timer. If this doesn't happen, the device must have crashed, and it will be automatically rebooted by the watchdog. if( loop_counter >= SECONDS_BETWEEN_HEARTBEAT_TRANSMISSION ){ // If a couple of minutes have passed, tell the controller we're still here loop_counter = 0; Serial.println(F(""Sending heartbeat"")); sendHeartbeat(); if( modem_booted == false && modem.available() == 0 && modem_state == WAITING_FOR_RESPONSE_FROM_MODEM ){ // If the boot process never (fully) ran, then this allows for a retry. modem_counter = 0; modem_state = MODEM_BUFFER_EMPTY; #ifdef ALLOW_CONNECTING_TO_NETWORK send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""Modem not responding"") )); wait(RADIO_DELAY); #endif #ifdef DEBUG Serial.println(F(""Resetting modem state"")); #endif } } else{ loop_counter++; } } // // Manage power to the locks // for( byte checkingDoor = 0; checkingDoor < DOOR_COUNT; checkingDoor++ ){ // We loop over all the doorlocks in the system, and check if they are in the right position. //Serial.print(F(""checkingDoor "")); Serial.println(checkingDoor); if( desired_door_states[checkingDoor] != actualDoorStates[checkingDoor] ){ Serial.println(F(""Changing door status"")); char updateMessage[11]; if( desired_door_states[checkingDoor] == LOCKED ){ digitalWrite(RELAY1_PIN + checkingDoor, RELAY_LOCKED); strcpy_P(updateMessage, lockedMessage); // Copy the string "" locked"" from PROGMEM / FLASH into RAM } else if( desired_door_states[checkingDoor] == UNLOCKED ){ digitalWrite(RELAY1_PIN + checkingDoor, RELAY_UNLOCKED); strcpy_P(updateMessage, unlockedMessage); // Copy the string "" unlocked"" from PROGMEM / FLASH into RAM } updateMessage[0] = checkingDoor + 49; // Here the first character of the string is changed to create a useful message, such as ""1 locked"" or ""2 unlocked"". Ascii character '1' has number 49. 2 has number 50, etc. #ifdef DEBUG Serial.print(F(""updateMessage: ""));Serial.println(updateMessage); Serial.print(F(""relay ID: "")); Serial.println(RELAY1_CHILD_ID + checkingDoor); Serial.print(F(""new desired state: "")); Serial.println(desired_door_states[checkingDoor]); #endif #ifdef ALLOW_CONNECTING_TO_NETWORK if( transmission_state ){ send(lock_message.setSensor(RELAY1_CHILD_ID + checkingDoor).set( desired_door_states[checkingDoor] )); wait(RADIO_DELAY); // Tell the controller in what state the lock is. send(text_message.setSensor(DEVICE_STATUS_ID).set( updateMessage )); wait(RADIO_DELAY); } #endif actualDoorStates[checkingDoor] = desired_door_states[checkingDoor]; EEPROM.update(EEPROM_STORAGE_START + RELAY1_CHILD_ID + checkingDoor, desired_door_states[checkingDoor]); // Store the new position in eeprom. After a reboot it will automatically jump back to this state. } } #ifdef DOOR1_SELF_LOCKING if( actualDoorStates[0] == UNLOCKED ){ Serial.println(F(""Self locking in a few seconds"")); wdt_disable(); wait(SELF_LOCKING_DELAY * 1000); wdt_enable(WDTO_8S); desired_door_states[0] = LOCKED; } #endif #ifdef DOOR2_SELF_LOCKING if( actualDoorStates[1] == UNLOCKED ){ Serial.println(F(""Self locking in a few seconds"")); wdt_disable(); wait(SELF_LOCKING_DELAY * 1000); wdt_enable(WDTO_8S); desired_door_states[1] = LOCKED; } #endif #ifdef HAS_BUTTONS // Check button to toggle the state if (digitalRead(BUTTON1_PIN) == HIGH){ //Serial.println(F(""1"")); wait(100); if(buttonBeingPressed == 0){ desired_door_states[0] = !desired_door_states[0]; // On press of the button, toggle the door 1 desired status. e.g. locked -> unlocked. #ifdef ALLOW_CONNECTING_TO_NETWORK if( transmission_state ){ send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""Button 1 pressed"") )); wait(RADIO_DELAY); } #endif Serial.print(F(""Button1->"")); Serial.println(desired_door_states[0]); } buttonBeingPressed = 1; } else if (digitalRead(BUTTON2_PIN) == HIGH){ //Serial.println(F(""2"")); wait(100); if(buttonBeingPressed == 0){ desired_door_states[1] = !desired_door_states[1]; // On press of the button, toggle the door 2 desired status. e.g. locked -> unlocked. #ifdef ALLOW_CONNECTING_TO_NETWORK if( transmission_state ){ send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""Button 2 pressed"") )); wait(RADIO_DELAY); } #endif Serial.print(F(""Button2->"")); Serial.println(desired_door_states[1]); } buttonBeingPressed = 1; } else{ buttonBeingPressed = 0; } #endif // // CHECK FOR INCOMING DATA FROM MODEM // if( modem.available() > 0 ){ char singleChar = modem.read(); #ifdef DEBUG //Serial.print(number_of_bytes_received); Serial.print(F(""="")); Serial.write(singleChar); Serial.print(F("" ("")); Serial.print( (byte) singleChar); //Serial.print(F(""), to go = "")); Serial.println( modem.available() ); #endif if( singleChar != 0 ){ // Ignore Null character. This gets sent by the modem once in a while. serial_line[number_of_bytes_received] = singleChar; number_of_bytes_received++; if( modem_state == WAITING_FOR_RESPONSE_FROM_MODEM ){ // We got a proper response from the modem. Serial.print(F("">>Got response from modem >"")); Serial.println( modem.available() ); modem_state = MODEM_PROCESSING_RESPONSE; } } char peek_char = 49; // ascii 1. Doesn't matter what it is really. if( modem.available() > 0 ){ peek_char = modem.peek(); //Serial.print(F(""-peek = "")); Serial.println(peek_char); if( peek_char == 10 ){ //Serial.println(F(""removing peek"")); modem.read(); // Clear the CR and LF from the buffer. } } if( (singleChar == 13 && peek_char == 10) || number_of_bytes_received == SERIAL_LINE_LENGTH ){ // Each line of text the modem sends ends with two special characters, the line feed (LF) and Carriage return (CR). We don't need those anymore. //Serial.print(F(""Received a line with a length of "")); Serial.println(number_of_bytes_received); serial_line[number_of_bytes_received] = '\\0'; number_of_bytes_received = 0; //Serial.println(serial_line); //Serial.print(F("" -to go: "")); Serial.println( modem.available() ); // After this line, how many more characters are there left in the buffer. processLine(); } if( modem.available() == 0 ){ if( modem_state == MODEM_PROCESSING_RESPONSE && number_of_bytes_received == 0 ){ //Serial.println(F(""Response buffer processed"")); modem_state = MODEM_BUFFER_EMPTY; } #ifdef DEBUG if( number_of_bytes_received != 0 ){ Serial.println(F(""Yikes, buffer is empty but serial_line is not complete. Buffer overflow happened?"")); number_of_bytes_received = 0; } #endif } } } // End of main loop // PROCESS LINE // // This parses the serial data from the GSM modem, and for example filters out the actual SMS text. void processLine() { #ifdef DEBUG Serial.print(F(""processing: "")); Serial.println(serial_line); //send(text_message.setSensor(SMS_CHILD_ID).set(serial_line)); wait(RADIO_DELAY); #endif // If the incomingSMS has been set, that means we already found the phonenumber part of the sms, and are now at the actual sms content part. if ( incomingSMS == 1 ){ incomingSMS = 0; // Reset for when the next sms needs to be dissected. #ifdef DEBUG Serial.println(F(""-At the actual text"")); #endif // Does the SMS content begin with a correct password? byte password1length = strlen(rotatingPassword1); byte password2length = strlen(rotatingPassword2); bool password1found = strncmp(serial_line, rotatingPassword1, password1length); bool password2found = strncmp(serial_line, rotatingPassword2, password2length); password1found = !password1found; password2found = !password2found; #ifdef DEBUG Serial.print(F(""pass 1 found?: ""));Serial.println(password1found); Serial.print(F(""pass 2 found?: ""));Serial.println(password2found); #endif if( password1found || password2found ){ // If password matches, and using SMS to control the lock is allowed Serial.println(F(""Correct password received"")); if( sms_control_state ){ char * command; command = strstr(serial_line, "" ""); // Search for the index of the space if (command != NULL) // If successful then command now points to the second word in the SMS { // Serial.print(F(""Command = "")); Serial.println(command); // Check what the command is, and act on it. bool commandLock = strncmp (command, "" lock"", 5); bool commandUnlock = strncmp (command, "" unlock"", 7); bool commandStatus = strncmp (command, "" status"", 7); if(commandLock == 0){ Serial.println(F(""->lock"")); if(password1found){ desired_door_states[0] = LOCKED; } if(password2found){ desired_door_states[1] = LOCKED; } } else if(commandUnlock == 0){ Serial.println(F(""->unlock"")); if(password1found){ desired_door_states[0] = UNLOCKED; } if(password2found){ desired_door_states[1] = UNLOCKED; } } else if(commandStatus == 0){ Serial.println(F(""command: send status sms"")); //char updateMessage[11]; if( password1found ){ // If it's zero, it means it was found. if( actualDoorStates[0] == LOCKED ){ strcpy_P(work_string, lockedMessage); } else { strcpy_P(work_string, unlockedMessage); } work_string[0] = 49; // ascii 1 } if( password2found ){ if( actualDoorStates[1] == LOCKED ){ strcpy_P(work_string, lockedMessage); } else { strcpy_P(work_string, unlockedMessage); } work_string[0] = 50; // ascii 2 } Serial.println(F(""Status SMS: "")); Serial.println(work_string); sendSMS(); // Sends the work_string array, which now contains a message about the door's lock status } } } } else { // If the SMS did not contain a good password, we will send it to the controller. Serial.println(F(""Incorrect password"")); //char tempLine[25]; //byte i = 25; // How many characters we will copy into the new variable //while ( i-- ) *( tempLine + i ) = *( serial_line + i ); // Copying characters from serial_line variable into a new one. //send(text_message.setSensor(SMS_CHILD_ID).set(tempLine)); wait(RADIO_DELAY); #ifdef ALLOW_CONNECTING_TO_NETWORK if( transmission_state ){ serial_line[24] = '\\0'; send(text_message.setSensor(SMS_CHILD_ID).set(serial_line)); wait(RADIO_DELAY); } #endif } Serial.println(F(""Deleting SMS message"")); modem.println(F(""AT+CMGD=1,4"")); // Delete all received SMS messages (for A6 based GSM modem). } else { //bool connectedToNetwork = strncmp(serial_line, ""+CREG: 5"", 8); //if (connectedToNetwork == 0){ if( !strncmp(serial_line, ""+CREG: 5"", 8) ){ // Connected to the GSM network Serial.println(F(""GSM CONNECTED"")); #ifdef ALLOW_CONNECTING_TO_NETWORK send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""GSM OK""))); wait(RADIO_DELAY); #endif } else if( !strncmp(serial_line, ""+CMS ERR"", 8) ){ // Counter intuitively, if the string matches, the result is 0. In this case, the modem tells us there is an error. After an attempt to send an SMS, this could indicate a lack of network connection or lack of funds. Serial.println(F(""GSM ERROR (no network or funds?)"")); #ifdef ALLOW_CONNECTING_TO_NETWORK if( transmission_state ){ serial_line[24] = '\\0'; Serial.println(serial_line); send(text_message.setSensor(SMS_CHILD_ID).set(serial_line)); wait(RADIO_DELAY); wait(1000); send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""GSM network error (CMS)"") )); wait(RADIO_DELAY); wait(2000); send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""Check funds or phone #1"") )); wait(RADIO_DELAY); } #endif } else if( !strncmp(serial_line, ""+CME ERR"", 8) ){ // This error could occus if a user sends an incorrect code to their mobile provider Serial.println(F(""GSM ERROR (incorrect code sent?)"")); #ifdef ALLOW_CONNECTING_TO_NETWORK if( transmission_state ){ serial_line[24] = '\\0'; send(text_message.setSensor(SMS_CHILD_ID).set(serial_line)); wait(RADIO_DELAY); //send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""GSM error (CME)"") )); wait(RADIO_DELAY); //wait(1000); } #endif } // We can send special commands to the modem. The response is encoded in a 7 bit instead of 8 bit way, and needs to be decoded. else if( !strncmp(serial_line, ""+CUSD:"", 6) ){ // We received the response from the *# command. Serial.println(F(""Decoding"")); // Serial.println(serial_line); byte commandPos = 11; // 11 is the position in the character array where the returned command actually starts. byte savePos = 0; // The position in the array where we are storing the new value. //static byte shift = 0; // How many of the bits must be shifted over to the next byte. Since are are handling 8 bits but only need 7, we keep having one bit left over. Once there is a need to shift 7 bits, that means we have the extra 'bonus' character. byte shift = 0; // How many of the bits must be shifted over to the next byte. Since are are handling 8 bits but only need 7, we keep having one bit left over. Once there is a need to shift 7 bits, that means we have the extra 'bonus' character. //Serial.print(F(""shift = "")); Serial.println(shift); byte nextLeftOver = 0; // The leftover bits from the current translation byte prevLeftOver = 0; // The leftover bits from the previous translation. //char value = 49 while ( commandPos < SERIAL_LINE_LENGTH ){ //sizeof(serial_line) ){ // was 255 // Alternatively, the reserved size of the serial_line array is simply SERIAL_LINE_LENGTH prevLeftOver = nextLeftOver; nextLeftOver = 0; boolean should_send_line = false; char value = serial_line[commandPos]; // Get a character from the serial data. if( value == 0 ){ //Serial.println(F(""found NULL"")); // Shouldn't really happen? //should_send_line = true; break; } //Serial.print(commandPos); Serial.print(F(""="")); Serial.write(value); Serial.println(F("" "")); if( savePos == 24 || value == 34 || value == 0 ){ //if( should_send_line ){ work_string[savePos] = '\\0'; savePos = 0; // Set the postion of the write head back to 0. #ifdef DEBUG Serial.println(work_string); #endif #ifdef ALLOW_CONNECTING_TO_NETWORK if( transmission_state ){ send(text_message.setSensor(DEVICE_STATUS_ID).set( work_string )); wait(RADIO_DELAY); } #endif wait(2000); // Allows the user to read the response more easily if it has multiple lines. } if( value == 34 ){ // We're at the end of the serial_line. //Serial.println(F(""found closing \\"""")); break; } // Here we safeguard the bits we will need in the next round by copying them into a new variable. for( byte j = 0; j <= shift; j++ ){ bitWrite( nextLeftOver, j, bitRead(value,(7-shift) + j) ); } value = value << shift; // Scoot everything over. The bits that get destroyed have already been safeguarded. value = value | prevLeftOver; // overlay the previous left over bits. This will create the final character. //Serial.print("">""); Serial.println(value); bitWrite( value, 7, 0 ); // Force it to be a 7-bit character by turning the 8th bit to 0. //Serial.print("">""); Serial.print( (char) value); //Serial.print("">""); Serial.print( (char) value); Serial.print("">""); Serial.println(value); work_string[savePos] = value; // Store the final decoded value back in the original serial_line array (to save memory). savePos++; shift++; if( shift == 7 ){ //Serial.print( (char) nextLeftOver); // Once every 7 loops the left-over part will itself be 7 bits long. We can just print this as the 7th character. work_string[savePos] = (char) nextLeftOver; //value; // Store the final decoded value back in the original array. savePos++; nextLeftOver = 0; shift = 0; } commandPos++; } Serial.println(); } else if( !strncmp(serial_line, ""+CMT:"", 4) ){ // Are we at the part of the SMS that holds the sender's phonenumber? #ifdef DEBUG Serial.println(F(""+CMT found"")); // Can we find a phonenumber in the serial line? Serial.print(F(""phone#1 to check against = "")); Serial.println(phone1); Serial.print(F(""phone#2 to check against = "")); Serial.println(phone2); #endif char * p; char * q; //byte p; //byte q; p = strstr (serial_line, phone1); // At what position in the serial_line have we spotted the phone number? If it is 0 this means it has not been found. q = strstr (serial_line, phone2); if (p || q) { // If one of the phone numbers was found in the string, then one of these will be bigger than 0. Serial.println(F(""Phone number is allowed"")); incomingSMS = 1; // We may now proces the sms content, which should be on the next serial line. #ifdef DEBUG Serial.print(F(""Buffer still available: "")); Serial.println( modem.available() ); #endif return; //char foundNumber[15]; //memcpy( foundNumber, &serial_line[8], 10 ); // Starts at position 10 in the serial_line and then copies 12 characters } else { Serial.println(F(""Permission denied for: "")); // Neither allowed phone number was detected. Fun fact: if the two phone number arrays to compare against are """" (empty), the above should also trigger, which means any phone number may control the device if no phone numbers are set. char foundNumber[14]; // Holds the phone number that sent the SMS for (byte i = 8; i < 20; i++) { char character = serial_line[i]; if( isDigit(character) ){ Serial.write(character); foundNumber[i - 8] = character; foundNumber[i - 7] = '\\n'; } } Serial.println(); // Send the unexpected phone number: #ifdef ALLOW_CONNECTING_TO_NETWORK send(text_message.setSensor(DEVICE_STATUS_ID).set(F(""Unknown phone number!""))); wait(RADIO_DELAY); send(text_message.setSensor(SMS_CHILD_ID).set( foundNumber )); wait(RADIO_DELAY); // Tell the controller which phone number just sent us an SMS. #endif } } } } #ifdef ALLOW_CONNECTING_TO_NETWORK // This function is called when messages from the home controller arrive. void receive(const MyMessage &message) { //timeOutCount = 0; #ifdef DEBUG Serial.print(F(""->receiving message for child "")); Serial.println(message.sensor); #endif if( message.isAck() ){ #ifdef DEBUG Serial.println(F(""- Echo"")); #endif } else if( message.type == V_LOCK_STATUS ){ // Change lock state desired_door_states[message.sensor - RELAY1_CHILD_ID] = message.getBool()?RELAY_LOCKED:RELAY_UNLOCKED; Serial.print(F(""Controller -> door "")); Serial.print(message.sensor - RELAY1_CHILD_ID); Serial.print(F("" -> "")); Serial.println(desired_door_states[message.sensor - RELAY1_CHILD_ID]); if( !transmission_state ){ // We only echo this state back to the controller straight from the receive function if the main loop won't update the controller because the data transmission is disabled. send(lock_message.setSensor(message.sensor).set( message.getBool() )); // Tell the controller that the value was received. } } else if( message.type == V_STATUS ){ send(relay_message.setSensor(message.sensor).set( message.getBool() )); if( message.sensor == TRANSMISSION_STATE_CHILD_ID ){ // Data transmission toggle desired_transmission_state = message.getBool(); //?RELAY_ON:RELAY_OFF; //send(relay_message.setSensor(TRANSMISSION_STATE_CHILD_ID).set(desired_transmission_state)); Serial.print(F(""-New desired transmission state: "")); Serial.println(desired_transmission_state); } else if( message.sensor == SMS_CONTROL_ID ){ // SMS control toggle desired_sms_control_state = message.getBool(); //?RELAY_ON:RELAY_OFF; //send(relay_message.setSensor(SMS_CONTROL_ID).set(desired_sms_control_state)); Serial.print(F(""-New desired sms control state: "")); Serial.println(desired_sms_control_state); } } else if( message.type == V_TEXT ){ Serial.print(F(""- incoming string: ""));Serial.println(message.getString()); send(text_message.setSensor(message.sensor).set( message.getString() )); // Tell the controller that the value was received. // If the controller asks us to send an SMS. if( message.sensor == SENDSMS_CHILD_ID ){ //strcpy(smsToSend, message.getString()); strcpy(work_string, message.getString()); send_sms = true; //send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""Sending SMS...""))); } if( message.sensor == ROTATING_PASSWORD1_ID ){ if( rotatingPassword1 != message.getString() ){ strcpy(rotatingPassword1, message.getString()); Serial.print(F(""Rotating password 1 is now: "")); Serial.println(rotatingPassword1); store_to_eeprom = true; //send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""received latest password 1""))); wait(RADIO_DELAY); } } else if( message.sensor == ROTATING_PASSWORD2_ID ){ if( rotatingPassword2 != message.getString() ){ strcpy( rotatingPassword2, message.getString()); Serial.print(F(""Rotating password 2 is now: "")); Serial.println(rotatingPassword2); store_to_eeprom = true; //send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""received latest password 2""))); wait(RADIO_DELAY); } } // Receiving the (parts of) phonenumbers that are allowed to operate the smart lock. else if( message.sensor == PHONENUMBER1_ID ){ strcpy(phone1, message.getString()); store_to_eeprom = true; Serial.println(F(""received phone #1 "")); #ifdef DEBUG Serial.print(F(""phone1: "")); Serial.println(phone1); #endif } else if( message.sensor == PHONENUMBER2_ID ){ //if( sizeof(message.getString()) > 2 ){ strcpy(phone2, message.getString()); store_to_eeprom = true; //} Serial.println(F(""received phone #2 "")); #ifdef DEBUG Serial.print(F(""phone2: "")); Serial.println(phone2); #endif } // If could also be that the Status and Received SMS string are sent back. Those should just be ignored. } } #endif // connecting to network // Function to send an SMS to the main phone number. void sendSMS() { boolean placeholder = strstr(work_string, ""Change me to send SMS""); if( modem_booted && modem_state == MODEM_BUFFER_EMPTY && placeholder == NULL){ #ifdef DEBUG Serial.print(F(""In sendSMS. string = "")); Serial.println(work_string); Serial.println(placeholder); #endif //boolean actual_new_SMS_message = strstr(work_string, ""Change me to send SMS""); // Search for the index //if (actual_new_SMS_message == NULL){ // If successful then command now points to the second word in the SMS byte i = 0; char c = 49; if( work_string[0] == 42 ){ // Detect is the SMS to send starts with a *. If so, it will be parsed as command to the telephony provider. For example, with LycaMobile the code *101# will tell you your balance, and *102# will tell you your phone number. Serial.println(F(""starts with *"")); boolean contains_hash_character = false; while( c != 35 && i < WORK_STRING_SIZE ){ if( work_string[i] == 35 ){ // ascii character 35 is the # //Serial.println(F(""#"")); contains_hash_character = true; // We only send the command if the string contains a closing # too. } i++; } if( contains_hash_character ){ modem_state = WAITING_FOR_RESPONSE_FROM_MODEM; #ifdef ALLOW_CONNECTING_TO_NETWORK send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""..."") )); wait(RADIO_DELAY); #endif //while( modem.available() ){ // The response may be large, so in this case we clear the existing buffer. // modem.read(); //} modem.print(F(""AT+CUSD=1,\\"""")); i = 0; c = 49; while( c != 35 && i < WORK_STRING_SIZE ){ // While we're not at the closing # in the command yet, we print the characters of the command c = work_string[i]; // Could this step be skipped, and just print work_string[i] directly? //Serial.println(c); modem.write(c); i++; } modem.println(F(""\\"",15"")); // Send a request for data to your provider, such as your prepaid balance or your phone number. modem_state = WAITING_FOR_RESPONSE_FROM_MODEM; } } else if( (work_string[0] == 43 || work_string[0] == 48) && isDigit(work_string[1]) && isDigit(work_string[2]) ){ //&& work_string[1] > 47 && work_string[1] < 58){ // The numbers 43 and 48 are the ascii codes for + and 0 respectively Serial.println(F(""String started with 0 or +"")); // We can only send an SMS is the SMS starts with a phone number. modem_state = WAITING_FOR_RESPONSE_FROM_MODEM; modem.print(F(""AT+CMGS=\\"""")); i = 0; c = 49; boolean at_actual_content = false; while( c != 0 && i < WORK_STRING_SIZE ){ c = work_string[i]; /* if( at_actual_content == false && c > 57){ // If we detect an alphabetical letter, perhaps the user has forgotten to use a space after the phone number. Here we add it manually. Serial.println(F(""User forgot space?"")); c = "" ""; i--; } */ if( c == 32 && at_actual_content == false ){ // 32 is the ascii code for a space at_actual_content = true; modem.print(F(""\\""\\r"")); Serial.print(F(""]Space["")); wait(500); } modem.write(c); Serial.write(c); i++; } if( at_actual_content == false ){ // The string never contained a space / sms text, so we use a default one. modem.print(F(""\\""\\r"")); wait(500); modem.print(F(""Smart lock says hello"")); } //modem.write(0x1A); // The command to actually send away the SMS. modem.println( char(26) ); modem_state = WAITING_FOR_RESPONSE_FROM_MODEM; Serial.println(F(""]SMS sent"")); #ifdef ALLOW_CONNECTING_TO_NETWORK send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""SMS passed to modem"") )); wait(RADIO_DELAY); #endif } else if( phone1[0] == 43 || phone1[0] == 48 ){ // The numbers 43 and 48 are the ascii codes for + and 0 respectively Serial.println(F(""Using phone #1"")); modem.print(F(""AT+CMGS=\\"""")); modem.print(phone1); modem.println(F(""\\""\\r"")); wait(200); //modem.print(""test message from A6""); i = 0; c = 49; while( c != 0 && i < WORK_STRING_SIZE ){ c = work_string[i]; modem.write(c); Serial.write(c); i++; } modem.println (char(26)); // ctrl-z /* modem.print(F(""AT+CMGS=\\"""")); i = 0; c = 49; boolean at_actual_content = false; while( c != 0 && i < sizeof(phone1) ){ c = phone1[i]; modem.write(c); Serial.write(c); i++; } modem.println(F(""\\""\\r"")); Serial.print(F(""]Space["")); */ /* wait(200); i = 0; c = 49; while( c != 0 && i < WORK_STRING_SIZE ){ c = work_string[i]; modem.write(c); Serial.write(c); i++; } modem.write(0x1A); // The command to actually send away the SMS. */ Serial.println(F(""]SMS sent to phone1"")); modem_state = WAITING_FOR_RESPONSE_FROM_MODEM; #ifdef ALLOW_CONNECTING_TO_NETWORK send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""SMS sent to phone 1""))); wait(RADIO_DELAY); #endif } else{ Serial.println(F(""No good phone number set, so cannot send SMS"")); #ifdef ALLOW_CONNECTING_TO_NETWORK if( transmission_state ){ send(text_message.setSensor(DEVICE_STATUS_ID).set( F(""No phone number 1""))); wait(RADIO_DELAY); } #endif } #ifdef ALLOW_CONNECTING_TO_NETWORK send(text_message.setSensor(SENDSMS_CHILD_ID).set( F(""Change me to send SMS""))); //wait(RADIO_DELAY); #endif wait(1000); } #ifdef DEBUG else{ Serial.println(F(""Will/can not send this SMS"")); } #endif } #ifdef JESSE boolean motor_switch(boolean destination) { Serial.print(F(""Motor switching to "")); Serial.println(destination); //Serial.println(F(""This list of measurements should start with 1 and end with 0"")); digitalWrite(MOTOR_FORWARD_PIN, !destination); digitalWrite(MOTOR_BACKWARD_PIN, destination); boolean error = false; byte counter = 0; if(destination == false){ // Moving to on state, in which the bototm switch is 1 and the top switch is 0. while( digitalRead(BOTTOM_MOTOR_SWITCH_PIN) ){ // While the bottom switch reads 1 it is not being pressed. When it is pressed, it will go to 0, and exit this loop. wait(3); Serial.println(digitalRead(BOTTOM_MOTOR_SWITCH_PIN)); counter++; if(counter > 100){ // This is a safety feature to exit the loop if something strange is going on. Serial.print(F(""break"")); error = true; break; } } } else{ while( digitalRead(TOP_MOTOR_SWITCH_PIN) ){ wait(3); Serial.println(digitalRead(TOP_MOTOR_SWITCH_PIN)); counter++; if(counter > 100){ error = true; Serial.print(F(""break"")); break; } } } digitalWrite(MOTOR_FORWARD_PIN, LOW); digitalWrite(MOTOR_BACKWARD_PIN, LOW); if( error == false ){ //EEPROM.update(EEPROM_STORAGE_START + TRANSMISSION_STATE_CHILD_ID, transmission_state); // We remember the current state of the toggle switch. Serial.println(F(""WENT OK"")); return destination; Serial.print(F(""-Motor switched. New transmission state: "")); Serial.println(transmission_state); } else{ Serial.println(F(""ERROR motor swiching to the new position got stuck in an endless loop"")); wait(400); // Give the motor some time to cool down ever so slightly Serial.println(F(""ERROR motor swiching to the new position got stuck in an endless loop cooler done"")); return !digitalRead(TOP_MOTOR_SWITCH_PIN); // If the top switch (which is the main one that determines the transmission state) is in the on state, the top switch will read as 0, so we invert it. } } #endif // Jesse void storeToEeprom(char TheArray[], int n, int eeprom_starting_position) // Currently not used, but could be used to improve the code { //Serial.println(F(""storing to eeprom: "")); char c = 49; // ""1"", a random non-null character for ( int i = 0; i < n; i++ ){ if( c != '\\0'){ // After we find the zero that terminiates the string, we keep writing zeros to the rest of the eeprom storage location. c = TheArray[i]; } //Serial.print(i); Serial.print(F(""="")); Serial.println(c); EEPROM.update(eeprom_starting_position + i, c); } } void loadFromEeprom(char TheArray[], int n, int eeprom_starting_position) { //Serial.println(F(""loading from eeprom: "")); for ( int i = 0; i < n; i++ ){ TheArray[i] = EEPROM.read(eeprom_starting_position + i); //Serial.print(i); Serial.print(F(""="")); Serial.println(TheArray[i]); } } void storeEverythingToEeprom(){ #ifdef DEBUG Serial.println(F(""{{ Storing everything to eeprom"")); #endif EEPROM.update(EEPROM_STORAGE_START + 255,1); // Indicates that the eeprom now contains user data. storeToEeprom(rotatingPassword1, 26, EEPROM_STORAGE_START + ROTATING_PASSWORD1_ID); storeToEeprom(rotatingPassword2, 26, EEPROM_STORAGE_START + ROTATING_PASSWORD2_ID); storeToEeprom(phone1, 15, EEPROM_STORAGE_START + PHONENUMBER1_ID); // To be more future proof, we store the phone numbers a little higher than the passwords so that we could store 4 passwords (at positions 10, 36, 52 87), and then 4 phone numbers (120, 135, 150, 165) storeToEeprom(phone2, 15, EEPROM_STORAGE_START + PHONENUMBER2_ID); } void loadEverythingFromEeprom(){ #ifdef DEBUG Serial.println(F(""}} Loading everything from eeprom"")); #endif loadFromEeprom(rotatingPassword1, 26, EEPROM_STORAGE_START + ROTATING_PASSWORD1_ID); loadFromEeprom(rotatingPassword2, 26, EEPROM_STORAGE_START + ROTATING_PASSWORD2_ID); loadFromEeprom(phone1, 15, EEPROM_STORAGE_START + PHONENUMBER1_ID); loadFromEeprom(phone2, 15, EEPROM_STORAGE_START + PHONENUMBER2_ID); } /* * * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * */ ",16166,True,2800.723149824565,median "/** * MetroMiniABS.ino -- An OpenLCB node that implements a single Automatic Block * Signal. This node presumes the hardware detailed at * https://github.com/RobertPHeller/RPi-RRCircuits/tree/master/MetroMiniABS * This board uses an Adafruit Metro Mini, which is a Arduino Uno R3 clone on * a mini form factor: 1.7""x.7"", with 28 pins as two rows of 14 .6"" with a .1"" * pitch (same footprint as a wide DIL-28). * * I/O pin usage: * * D3 Red signal lamp (PWM) * D4 Blue Button/Led * D5 Yellow signal lamp (PWM) * D6 Green signal lamp (PWM) * D7 Gold Button/Led * D8 Occupancy Detector * * Events used: * * Consumed: * Next Block Occupied * Next Block Clear * Produced: * Block Occupied * Block Clear * Stop Aspect Triggered * Stop Aspect Released * Approach Aspect Triggered * Approach Aspect Released * Clear Aspect Triggered * Clear Aspect Released * * Additional configuration: * * Common Anode: Yes/No * BiPolar Searchlight: Yes/No * Stop (red) Brightness: 0-255 * Approach (yellow) Brightness: 0-255 * Clear (green) Brightness: 0-255 * Yellow Hue (ratio of red to green): 0-255 * */ // OlcbBasicNode // A prototype of a basic 4-channel OpenLCB board // // setup() determines which are consumers and // which are producers // // Bob Jacobsen 2010, 2012 // based on examples by Alex Shepherd and David Harris //============================================================== // next line for stand-alone compile #include #include #include #include #include #include ""logging.h"" // The following lines are needed because the Arduino environment // won't search a library directory unless the library is included // from the top level file (this file) #include #include #include #include ""ButtonLed_nobutton.h"" #include ""ButtonLed_nc.h"" #include ""ButtonLed_noled.h"" #include ""SignalOptions.h"" #include ""Mast.h"" #include ""OlcbCommonVersion.h"" #include ""NodeID.h"" // init for serial communications if used #define BAUD_RATE 57600 NodeID nodeid(0x05,0x01,0x01,0x01,0x22,0x80); // This node's default ID; must be valid // Define pins #define BLUE 4 #define GOLD 7 #define BLOCKOCC 8 // No led! #define SIGNALGREEN 6 // No button #define SIGNALYELLOW 5 // No button #define SIGNALRED 3 // No button ButtonLed_noled blockocc(BLOCKOCC,LOW); ButtonLed_nc nextblock(0); // No actual pin ButtonLed_nobutton signalgreen(SIGNALGREEN); ButtonLed_nobutton signalyellow(SIGNALYELLOW); ButtonLed_nobutton signalred(SIGNALRED); struct { char nodename[20]; char nodedescr[24]; SignalOptions signalOptions; } configOptions; Mast mast(&blockocc,&nextblock,&signalgreen,&signalyellow,&signalred, &(configOptions.signalOptions)); #define NUM_EVENT 10 // next lines get ""warning: only initialized variables can be placed into program memory area"" due to GCC bug extern ""C"" { const char configDefInfo[] PROGMEM = { 60, 63, 120, 109, 108, 32, 118, 101, 114, 115, 105, 111, 110, 61, 34, 49, 46, 48, 34, 63, 62, 10, 60, 63, 120, 109, 108, 45, 115, 116, 121, 108, 101, 115, 104, 101, 101, 116, 32, 116, 121, 112, 101, 61, 39, 116, 101, 120, 116, 47, 120, 115, 108, 39, 32, 104, 114, 101, 102, 61, 39, 104, 116, 116, 112, 58, 47, 47, 111, 112, 101, 110, 108, 99, 98, 46, 111, 114, 103, 47, 116, 114, 117, 110, 107, 47, 112, 114, 111, 116, 111, 116, 121, 112, 101, 115, 47, 120, 109, 108, 47, 120, 115, 108, 116, 47, 99, 100, 105, 46, 120, 115, 108, 39, 63, 62, 10, 60, 99, 100, 105, 32, 120, 109, 108, 110, 115, 58, // | Deepwoods Software MetroMiniABS 1.0 1.0 Node ID User-provided description of the node Node Name Node Description Signal Implementation Options Common Anode 1Yes 0No BiPolar Searchlight | 32, 32, 32, 32, 60, 109, 97, 112, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 114, 101, 108, 97, 116, 105, 111, 110, 62, 60, 112, 114, 111, 112, 101, 114, 116, 121, 62, 49, 60, 47, 112, 114, 111, 112, 101, 114, 116, 121, 62, 60, 118, 97, 108, 117, 101, 62, 89, 101, 115, 60, 47, 118, 97, 108, 117, 101, 62, 60, 47, 114, 101, 108, 97, 116, 105, 111, 110, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 114, 101, 108, 97, 116, 105, 111, 110, 62, 60, 112, 114, 111, 112, 101, 114, 116, 121, 62, 48, 60, 47, 112, 114, 111, 112, 101, 114, 116, 121, 62, 60, 118, 97, 108, // | 1Yes 0No Stop (red) Brightness<| 47, 110, 97, 109, 101, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, 105, 110, 116, 62, 10, 32, 32, 32, 32, 32, 32, 60, 105, 110, 116, 32, 115, 105, 122, 101, 61, 34, 49, 34, 32, 109, 105, 110, 61, 34, 48, 34, 32, 109, 97, 120, 61, 34, 50, 53, 53, 34, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 110, 97, 109, 101, 62, 65, 112, 112, 114, 111, 97, 99, 104, 32, 40, 121, 101, 108, 108, 111, 119, 41, 32, 66, 114, 105, 103, 104, 116, 110, 101, 115, 115, 60, 47, 110, 97, 109, 101, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, 105, 110, 116, 62, 10, 32, 32, 32, 32, 32, 32, // | /name> Approach (yellow) Brightness | 60, 105, 110, 116, 32, 115, 105, 122, 101, 61, 34, 49, 34, 32, 109, 105, 110, 61, 34, 48, 34, 32, 109, 97, 120, 61, 34, 50, 53, 53, 34, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 110, 97, 109, 101, 62, 67, 108, 101, 97, 114, 32, 40, 103, 114, 101, 101, 110, 41, 32, 66, 114, 105, 103, 104, 116, 110, 101, 115, 115, 60, 47, 110, 97, 109, 101, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, 105, 110, 116, 62, 10, 32, 32, 32, 32, 32, 32, 60, 105, 110, 116, 32, 115, 105, 122, 101, 61, 34, 49, 34, 32, 109, 105, 110, 61, 34, 48, 34, 32, 109, 97, 120, 61, 34, 50, 53, 53, // | Clear (green) Brightness Yellow Hue (ratio of red to green) Events Define events associated with input and output pins | 32, 32, 32, 60, 110, 97, 109, 101, 62, 66, 108, 111, 99, 107, 32, 69, 118, 101, 110, 116, 115, 60, 47, 110, 97, 109, 101, 62, 10, 32, 32, 32, 32, 32, 32, 60, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 110, 97, 109, 101, 62, 78, 101, 120, 116, 32, 66, 108, 111, 99, 107, 32, 79, 99, 99, 117, 112, 105, 101, 100, 60, 47, 110, 97, 109, 101, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 60, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, // | Block Events Next Block Occupied <| 110, 97, 109, 101, 62, 78, 101, 120, 116, 32, 66, 108, 111, 99, 107, 32, 67, 108, 101, 97, 114, 60, 47, 110, 97, 109, 101, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 60, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 110, 97, 109, 101, 62, 66, 108, 111, 99, 107, 32, 79, 99, 99, 117, 112, 105, 101, 100, 60, 47, 110, 97, 109, 101, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 60, 101, 118, 101, 110, 116, 105, // | name>Next Block Clear Block Occupied Block Clear Signal Aspect Events Stop Aspect Triggered Stop Aspect Released | 32, 32, 60, 47, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 60, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 110, 97, 109, 101, 62, 65, 112, 112, 114, 111, 97, 99, 104, 32, 65, 115, 112, 101, 99, 116, 32, 84, 114, 105, 103, 103, 101, 114, 101, 100, 60, 47, 110, 97, 109, 101, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 60, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 110, 97, 109, 101, 62, 65, 112, 112, 114, 111, // | Approach Aspect Triggered Appro| 97, 99, 104, 32, 65, 115, 112, 101, 99, 116, 32, 82, 101, 108, 101, 97, 115, 101, 100, 60, 47, 110, 97, 109, 101, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 60, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 110, 97, 109, 101, 62, 67, 108, 101, 97, 114, 32, 65, 115, 112, 101, 99, 116, 32, 84, 114, 105, 103, 103, 101, 114, 101, 100, 60, 47, 110, 97, 109, 101, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 60, // | ach Aspect Released Clear Aspect Triggered <| 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 110, 97, 109, 101, 62, 67, 108, 101, 97, 114, 32, 65, 115, 112, 101, 99, 116, 32, 82, 101, 108, 101, 97, 115, 101, 100, 60, 47, 110, 97, 109, 101, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, 101, 118, 101, 110, 116, 105, 100, 62, 10, 32, 32, 32, 32, 60, 47, 103, 114, 111, 117, 112, 62, 10, 32, 32, 60, 47, 115, 101, 103, 109, 101, 110, 116, 62, 10, 60, 47, 99, 100, 105, 62, 10, // | eventid> Clear Aspect Released | 0 }; const char SNII_const_data[] PROGMEM = ""\\001MetroMiniABS\\000Metro Mini Automatic Block Signal\\0001.0\\000"" OlcbCommonVersion ; // last zero in double-quote }; // end extern ""C"" #define SNII_var_data 94 #define SNII_var_offset 20 #define ShortBlinkOn 0x00010001L #define ShortBlinkOff 0xFFFEFFFEL // The patterns are not really used. The only LEDs are powered by PWM and the // Other ""ButtonLeds"" are input only (no led) or not connected at all and are // just a state. But the BG class wants them... long patterns[] = { ShortBlinkOff,ShortBlinkOn, ShortBlinkOff,ShortBlinkOn, ShortBlinkOff,ShortBlinkOn, ShortBlinkOff,ShortBlinkOn, ShortBlinkOff,ShortBlinkOn }; // Non of these are actual buttons with LEDs. One input, one state, and three // PWM outputs. ButtonLed* buttons[] = { &nextblock,&nextblock, &blockocc,&blockocc, &signalred,&signalred, &signalyellow,&signalyellow, &signalgreen,&signalgreen }; // These are actual buttons w/LEDs ButtonLed blue(BLUE, LOW); ButtonLed gold(GOLD, LOW); #include ""OlcbArduinoCAN.h"" /* ************************************************* * EEPROM memory layout * See NodeMemory.h for background info * * Internal data, not to be reset by user: * 0 - 3 Memory state flag * 4 - 5 Cycle count * 6 - 11 Node ID * * User configuration data: * 12 - 12+10*sizeof(Event) EventID storage * * 112 - 132 Node name (zero-term string, 20 bytes total) * 132 - 156 User comment (zero-term string, 24 bytes total) * * 12+44 - 12+44+10*sizeof(Event) Events plus description strings * SignalOptions follow... * *************************************************** */ #define LAST_EEPROM 12+44+NUM_EVENT*sizeof(Event) extern ""C"" { uint32_t spaceUpperAddr(uint8_t space) { // return last valid address switch (space) { case 255: return sizeof(configDefInfo) - 1; // CDI (data starts at zero) case 254: return RAMEND; // RAM from Arduino definition case 253: return LAST_EEPROM; // Configuration } return (uint32_t)3; } const uint8_t getRead(uint32_t address, int space) { if (space == 0xFF) { // Configuration definition information return pgm_read_byte(configDefInfo+address); } else if (space == 0xFE) { // All memory reads from RAM starting at first location in this program return *(((uint8_t*)&rxBuffer)+address); } else if (space == 0xFD) { // Configuration space is entire EEPROM return EEPROM.read(address); } else if (space == 0xFC) { // // used by ADCDI/SNII for constant data return pgm_read_byte(SNII_const_data+address); } else if (space == 0xFB) { // // used by ADCDI/SNII for variable data return EEPROM.read(SNII_var_data+address); } else { // unknown space return 0; } } void getWrite(uint32_t address, int space, uint8_t val) { if (space == 0xFE) { // All memory *(((uint8_t*)&rxBuffer)+address) = val; } else if (space == 0xFD) { // Configuration space EEPROM.write(address, val); } // all other spaces not written } uint8_t protocolIdentValue[6] = {0xD7,0x58,0x00,0,0,0}; // PIP, Datagram, MemConfig, P/C, ident, teach/learn, // ACDI, SNIP, CDI // Events this node can produce or consume, used by PCE and loaded from EEPROM by NM Event events[] = { // should be NUM_EVENT of these Event(), Event(), Event(), Event(), Event(), Event(), Event(), Event(), Event(), Event() }; void pceCallback(int index){ // invoked when an event is consumed; drive pins as needed // from index // // sample code uses inverse of low bit of pattern to drive pin all on or all off // (pattern is mostly one way, blinking the other, hence inverse) // //buttons[index]->on(patterns[index]&0x1 ? 0x0L : ~0x0L ); buttons[index]->state = !(index & 0x01); // Process mast... } } // extern ""C"" NodeMemory nm(0); // allocate from start of EEPROM void store() { nm.store(&nodeid, events, NUM_EVENT,(uint8_t *)&configOptions,sizeof(configOptions)); } PCE pce(events, NUM_EVENT, &txBuffer, &nodeid, pceCallback, store, &link); // Set up Blue/Gold configuration BG bg(&pce, buttons, patterns, NUM_EVENT, &blue, &gold, &txBuffer); bool states[] = {false, false, false, false}; // current input states; report when changed int scanIndex = 0; // On the assumption that the producers (inputs) and consumers (outputs) are consecutive, // these are used later to label the individual channels as producer or consumer #define FIRST_PRODUCER_CHANNEL_INDEX 0 #define LAST_PRODUCER_CHANNEL_INDEX 4 #define FIRST_CONSUMER_CHANNEL_INDEX 5 #define LAST_CONSUMER_CHANNEL_INDEX 5 extern ""C"" { void produceFromInputs() { // called from loop(), this looks at changes in input pins and // and decides which events to fire // with pce.produce(i); // The first event of each pair is sent on button down, // and second on button up. // // To reduce latency, only MAX_INPUT_SCAN inputs are scanned on each loop // (Should not exceed the total number of inputs, nor about 4) #define MAX_INPUT_SCAN 4 // for (int i = 0; i<(MAX_INPUT_SCAN); i++, scanIndex++) { // simply a counter of how many to scan if (scanIndex > (LAST_PRODUCER_CHANNEL_INDEX)) scanIndex = (FIRST_PRODUCER_CHANNEL_INDEX); if (states[scanIndex] != buttons[scanIndex*2]->state) { states[scanIndex] = buttons[scanIndex*2]->state; if (states[scanIndex]) { pce.produce(scanIndex*2); } else { pce.produce(scanIndex*2+1); } if (scanIndex == 0) { // Process mast logic... } } } } } // extern ""C"" /** * Setup does initial configuration */ void setup() { // set up serial comm; may not be space for this! //delay(250);Serial.begin(BAUD_RATE);logstr(""\\nOlcbBasicNode\\n""); // read OpenLCB from EEPROM //nm.forceInitAll(); // uncomment if need to go back to initial EEPROM state nm.setup(&nodeid, events, NUM_EVENT, (uint8_t*) &configOptions, (uint16_t)sizeof(configOptions), (uint16_t)LAST_EEPROM); if (configOptions.signalOptions.clear_brite == 0) { configOptions.signalOptions.reset(); store(); } // set event types, now that IDs have been loaded from configuration // newEvent arguments are (event index, producer?, consumer?) for (int i=2*(FIRST_PRODUCER_CHANNEL_INDEX); i<2*(LAST_PRODUCER_CHANNEL_INDEX+1); i++) { pce.newEvent(i,true,false); // producer } for (int i=2*(FIRST_CONSUMER_CHANNEL_INDEX); i<2*(LAST_CONSUMER_CHANNEL_INDEX+1); i++) { pce.newEvent(i,false,true); // consumer } Olcb_setup(); } void loop() { bool activity = Olcb_loop(); if (activity) { // blink blue to show that the frame was received blue.blink(0x1); } if (OpenLcb_can_active) { // set when a frame sent gold.blink(0x1); OpenLcb_can_active = false; } // handle the status lights blue.process(); gold.process(); } ",16256,True,4384.3719709128445,median "/* SelectionList.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8g2lib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Frame Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_3W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_F_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1306_72X40_ER_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" OLED //U8G2_SSD1322_NHD_256X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_MIDAS_128X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_WS_128X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_RAYSTAR_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_RAYSTAR_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_F_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_F_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_F u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_F u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_F_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_F_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7565_EA_DOGM128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_KS0713_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_KS0713_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_LX12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7567_HEM6432_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_F_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_F_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_F_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_IST7920_128X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_IST7920_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_LC7981_160X80_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_F u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FG with GND //U8G2_SED1330_240X128_F_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // A0 is dc pin! //U8G2_RA8835_NHD_240X128_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1604_JLX19264_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_DEM240064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_F_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_F_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, DOGXL240 Test Board //U8G2_UC1611_EW50850_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1617_JLX128128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1617_JLX128128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1638_160X128_F_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_MAX7219_64X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); //U8G2_MAX7219_32X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); //U8G2_MAX7219_8X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); //U8G2_LS013B7DH03_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_F_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list void setup(void) { // DOGS102 Shield (http://shieldlist.org/controlconnection/dogs102) // u8g2.begin(/* menu_select_pin= */ 5, /* menu_next_pin= */ 4, /* menu_prev_pin= */ 2, /* menu_home_pin= */ 3); // DOGM128 Shield (http://shieldlist.org/schmelle2/dogm128) + DOGXL160 Shield // u8g2.begin(/* menu_select_pin= */ 2, /* menu_next_pin= */ 3, /* menu_prev_pin= */ 7, /* menu_home_pin= */ 8); // MKR Zero Test Board //u8g2.begin(/*Select=*/ 0, /*Right/Next=*/ 1, /*Left/Prev=*/ 2, /*Up=*/ 4, /*Down=*/ 3, /*Home/Cancel=*/ A6); // Arduboy //u8g2.begin(/*Select=*/ A0, /*Right/Next=*/ 5, /*Left/Prev=*/ 9, /*Up=*/ 8, /*Down=*/ 10, /*Home/Cancel=*/ A1); // Arduboy DevKit u8g2.begin(/*Select=*/ 7, /*Right/Next=*/ A1, /*Left/Prev=*/ A2, /*Up=*/ A0, /*Down=*/ A3, /*Home/Cancel=*/ 8); // Arduboy 10 (Production) u8g2.setFont(u8g2_font_6x12_tr); } const char *string_list = ""Altocumulus\\n"" ""Altostratus\\n"" ""Cirrocumulus\\n"" ""Cirrostratus\\n"" ""Cirrus\\n"" ""Cumulonimbus\\n"" ""Cumulus\\n"" ""Nimbostratus\\n"" ""Stratocumulus\\n"" ""Stratus""; uint8_t current_selection = 0; void loop(void) { current_selection = u8g2.userInterfaceSelectionList( ""Cloud Types"", current_selection, string_list); if ( current_selection == 0 ) { u8g2.userInterfaceMessage( ""Nothing selected."", """", """", "" ok ""); } else { u8g2.userInterfaceMessage( ""Selection:"", u8x8_GetStringLineStart(current_selection-1, string_list ), """", "" ok \\n cancel ""); } } ",16217,True,4889.034666395181,median "//////////////////////////////////////////////////////////////////////////////// // // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the ""License""); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an ""AS IS"" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// package mx.controls.advancedDataGridClasses { /* import flash.display.DisplayObject; import flash.events.Event; */ import mx.controls.AdvancedDataGrid; import mx.controls.TextInput; import mx.controls.dataGridClasses.DataGridColumn; import mx.core.ClassFactory; import mx.core.IFactory; import mx.core.mx_internal; import mx.utils.StringUtil; import org.apache.royale.core.UIBase; import org.apache.royale.events.Event; use namespace mx_internal; //-------------------------------------- // Styles //-------------------------------------- //include ""../../styles/metadata/TextStyles.as""; /** * The background color of the column. * The default value is undefined, which means it uses the value of the * backgroundColor style of the associated AdvancedDataGrid control. * The default value for the AdvancedDataGrid control is 0xFFFFFF. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ [Style(name=""backgroundColor"", type=""uint"", format=""Color"", inherit=""no"")] /** * The name of a CSS style declaration for controlling other aspects of * the appearance of the column headers. * The default value is undefined, which means it uses the value of the * headerStyleName style of the associated AdvancedDataGrid control. * The default value for the AdvancedDataGrid control is * "".advancedDataGridStyles"". * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ [Style(name=""headerStyleName"", type=""String"", inherit=""no"")] /** * The number of pixels between the container's left border and its content * area. * There is no default value for this style. * An item renderer's setting of the paddingLeft property * is used to determine the default. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ //[Style(name=""paddingLeft"", type=""Number"", format=""Length"", inherit=""no"")] /** * The number of pixels between the container's right border and its content * area. * There is no default value for this style. * An item renderer's setting of the paddingRight property * is used to determine the default. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ //[Style(name=""paddingRight"", type=""Number"", format=""Length"", inherit=""no"")] /** * The AdvancedDataGridColumn class describes a column in an AdvancedDataGrid control. * There is one AdvancedDataGridColumn per displayable column, even if a column * is hidden or off-screen. * The data provider items of an AdvancedDataGrid control * can contain properties that are not displayed, * and therefore, do not need an AdvancedDataGridColumn. * An AdvancedDataGridColumn allows specification of the color and font of the text * in a column; specification of what kind of component displays the data for the column; * specification of whether the column is editable, sortable, or resizeable; * and specification of the text for the column header. * *

Notes:

    *
  • An AdvancedDataGridColumn only holds information about a column; * it is not the parent of the item renderers in the column.
  • *
  • If you specify an AdvancedDataGridColumn class without a dataField * property, you must specify a sortCompareFunction * property. Otherwise, sort operations may cause run-time errors.
*

* * @mxml * *

You use the <mx.AdvancedDataGridcolumn> tag to configure a column * of a AdvancedDataGrid control. * You specify the <mx.AdvancedDataGridcolumn> tag as a child * of the columns property in MXML. * The <mx.AdvancedDataGridcolumn> tag inherits all of the * tag attributes of its superclass, and adds the following tag attributes:

* *
 *  <mx:AdvancedDataGridColumn
 *  Properties 
 *    dataField=""No default""
 *    dataTipField=""No default""
 *    dataTipFunction=""No default""
 *    editable=""true|false""
 *    editorDataField=""text""
 *    editorHeightOffset=""0""
 *    editorUsesEnterKey=""false|true""
 *    editorWidthOffset=""0""
 *    editorXOffset=""0""
 *    editorYOffset=""0""
 *    formatter=""null""
 *    headerRenderer=""AdvancedDataGridHeaderRenderer""
 *    headerText=""No default""
 *    headerWordWrap=""undefined""
 *    imeMode=""null""
 *    itemEditor=""TextInput""
 *    itemRenderer=""AdvancedDataGridItemRenderer""
 *    labelFunction=""No default""
 *    minWidth=""20""
 *    rendererIsEditor=""false|true""
 *    resizable=""true|false""
 *    showDataTips=""false|true""
 *    sortable=""true|false""
 *    sortCompareFunction=""No default""
 *    sortDescending=""false|true""
 *    styleFunction=""No default""
 *    visible=""true|false""
 *    width=""100""
 *    wordWrap=""false|true""
 * 
 *  Styles
 *    backgroundColor=""0xFFFFFF""
 *    color=""No default.""
 *    disabledColor=""0xAAB3B3""
 *    fontAntiAliasType=""advanced""
 *    fontFamily=""No default""
 *    fontGridFitType=""pixel""
 *    fontSharpness=""0""
 *    fontSize=""No default""
 *    fontStyle=""normal|italic""
 *    fontThickness=""0""
 *    fontWeight=""normal|bold""
 *    headerStyleName=""No default""
 *    kerning=""false|true""
 *    letterSpacing=""0""
 *    paddingLeft=""0""
 *    paddingRight=""0""
 *    textAlign=""right|center|left""
 *    textDecoration=""none|underline""
 *    textIndent=""0""
 *  />
 *  
* * @see mx.controls.AdvancedDataGrid * * @see mx.styles.CSSStyleDeclaration * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 * @royalesuppresspublicvarwarning */ public class AdvancedDataGridColumn extends DataGridColumn {//extends CSSStyleDeclaration implements IIMESupport //include ""../../core/Version.as""; //-------------------------------------------------------------------------- // // Class variables // //-------------------------------------------------------------------------- //---------------------------------- // embeddedFontRegistry //---------------------------------- // private static var noEmbeddedFonts:Boolean; /** * @private * Storage for the embeddedFontRegistry property. * This gets initialized on first access, * not at static initialization time, in order to ensure * that the Singleton registry has already been initialized. */ // private static var _embeddedFontRegistry:IEmbeddedFontRegistry; /** * @private * A reference to the embedded font registry. * Single registry in the system. * Used to look up the moduleFactory of a font. */ /* private static function get embeddedFontRegistry():IEmbeddedFontRegistry { if (!_embeddedFontRegistry && !noEmbeddedFonts) { try { _embeddedFontRegistry = IEmbeddedFontRegistry( Singleton.getInstance(""mx.core::IEmbeddedFontRegistry"")); } catch (e:Error) { noEmbeddedFonts = true; } } return _embeddedFontRegistry; } */ private static var _defaultItemEditorFactory:IFactory; mx_internal static function get defaultItemEditorFactory():IFactory { if (!_defaultItemEditorFactory) _defaultItemEditorFactory = new ClassFactory(TextInput); return _defaultItemEditorFactory; } //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * Constructor. * * @param columnName The name of the field in the data provider * associated with the column, and the text for the header cell of this * column. This is equivalent to setting the dataField * and headerText properties. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public function AdvancedDataGridColumn(columnName:String = null) { super(columnName); /* if (columnName) { dataField = columnName; headerText = columnName; } */ } //-------------------------------------------------------------------------- // // Variables // //-------------------------------------------------------------------------- // mx_internal var list:UIBase; //BaseEx; /** * @private */ // mx_internal var explicitWidth:Number; /** * @private * Holds the last recorded value of the module factory used to create the font. */ // private var oldEmbeddedFontContext:IFlexModuleFactory = null; /** * @private * * true if font properties do not need to be set. */ // private var fontPropertiesSet:Boolean = false; /** * @private * True if createInFontContext has been called. */ // private var hasFontContextBeenSaved:Boolean = false; // preferred width is the number we should use when measuring // regular width will be changed if we shrink columns to fit. // mx_internal var preferredWidth:Number = 100; //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- // ------------------------------------------------ // fontWeight // ------------------------------------------------ public function get fontWeight():String { return ""normal""; } public function set fontWeight(value:String):void { } // ------------------------------------------------ // fontSize // ------------------------------------------------ public function get fontSize():Number { return 11; } public function set fontSize(value:Number):void { } // ------------------------------------------------ // color // ------------------------------------------------ public function get color():uint { return 0x0B333C; } public function set color(value:uint):void { } //---------------------------------- // sortDescending //---------------------------------- /** * Indicates whether the column sort is * in ascending order, false, * or descending order, true. * * @default false * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ // public var sortDescending:Boolean = false; //---------------------------------- // dataTipField //---------------------------------- /** * @private * Storage for the dataTipField property. */ /* private var _dataTipField:String; [Bindable(""dataTipFieldChanged"")] [Inspectable(category=""Advanced"", defaultValue=""label"")] */ /** * The name of the field in the data provider to display as the data tip. * By default, the AdvancedDataGrid control looks for a property named * label on each data provider item and displays it. * However, if the data provider does not contain a label * property, you can set the dataTipField property to * specify a different property. * For example, you could set the value to ""FullName"" when a user views a * set of people's names included from a database. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ /* public function get dataTipField():String { return _dataTipField; } */ /** * @private */ /* public function set dataTipField(value:String):void { _dataTipField = value; if (owner) { owner.invalidateList(); } dispatchEvent(new Event(""dataTipChanged"")); } */ //---------------------------------- // dataTipFunction //---------------------------------- /** * @private * Storage for the dataTipFunction property. */ /* private var _dataTipFunction:Function; [Bindable(""dataTipFunctionChanged"")] [Inspectable(category=""Advanced"")] */ /** * Specifies a callback function to run on each item of the data provider * to determine its data tip. * This property is used by the itemToDataTip() method. * *

By default, the control looks for a property named label * on each data provider item and displays it as its dataTip. * However, some data providers do not have a label property * or another property that you can use for displaying data * in the rows. * For example, you might have a data provider that contains a lastName * and firstName fields, but you want to display full names as the dataTip. * You can specify a function to the dataTipFunction property * that returns a single String containing the value of both fields. You * can also use the dataTipFunction property for handling * formatting and localization.

* *

The function must take a single Object parameter, and return a String. * For the header cell of a column, the Object parameter is of type AdvancedDataGridColumn. * For table cells, the Object parameter contains the data provider element for the cell.

* *

Shown below is an example implementation of the function. * For the header cell, return ""Column Name"". * For the table cells, return the name property of the Object:

*
     *  private function tipFunc(value:Object):String
     *  {
     *      if (value is AdvancedDataGridColumn)
     *          return ""Column Name"";
     *                 
     *      // Use the 'name' property of the data provider element.
     *      return ""Name: "" + value[""name""];
     *  }
* * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ /* public function get dataTipFunction():Function { return _dataTipFunction; } */ /** * @private */ /* public function set dataTipFunction(value:Function):void { _dataTipFunction = value; if (owner) { owner.invalidateList(); } dispatchEvent(new Event(""labelFunctionChanged"")); } */ //---------------------------------- // draggable //---------------------------------- // [Inspectable(category=""General"")] /** * A flag that indicates whether the user is allowed to drag * the column to a new position * If true, the user can drag the * the column headers to a new position * * @default true * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ //public var draggable:Boolean = true; //---------------------------------- // editable //---------------------------------- //[Inspectable(category=""General"")] /** * A flag that indicates whether the items in the column are editable. * If true, and the AdvancedDataGrid's editable * property is also true, the items in a column are * editable and can be individually edited * by clicking an item or by navigating to the item with the * Tab and Arrow keys. * * @default true * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ //public var editable:Boolean = true; //---------------------------------- // itemEditor //---------------------------------- [Inspectable(category=""General"")] /** * A class factory for the instances of the item editor to use for the * column, when it is editable. * *

The default value is the mx.controls.TextInput control.

* * @see mx.controls.TextInput * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var itemEditor:IFactory = defaultItemEditorFactory; //---------------------------------- // editorDataField //---------------------------------- [Inspectable(category=""General"")] /** * The name of the property of the item editor that contains the new * data for the list item. * For example, the default itemEditor is * TextInput, so the default value of the editorDataField * property is ""text"", which specifies the * text property of the TextInput control. * * @default ""text"" * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var editorDataField:String = ""text""; //---------------------------------- // editorHeightOffset //---------------------------------- [Inspectable(category=""General"", defaultValue=""0"")] /** * The height of the item editor, in pixels, relative to the size of the * item renderer. This property can be used to make the editor overlap * the item renderer by a few pixels to compensate for a border around the * editor. * Note that changing these values while the editor is displayed * will have no effect on the current editor, but will affect the next * item renderer that opens an editor. * * @default 0 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var editorHeightOffset:Number = 0; //---------------------------------- // editorWidthOffset //---------------------------------- //[Inspectable(category=""General"", defaultValue=""0"")] /** * The width of the item editor, in pixels, relative to the size of the * item renderer. This property can be used to make the editor overlap * the item renderer by a few pixels to compensate for a border around the * editor. * Note that changing these values while the editor is displayed * will have no effect on the current editor, but will affect the next * item renderer that opens an editor. * * @default 0 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var editorWidthOffset:Number = 0; //---------------------------------- // editorXOffset //---------------------------------- // [Inspectable(category=""General"", defaultValue=""0"")] /** * The x location of the upper-left corner of the item editor, * in pixels, relative to the upper-left corner of the item. * This property can be used to make the editor overlap * the item renderer by a few pixels to compensate for a border around the * editor. * Note that changing these values while the editor is displayed * will have no effect on the current editor, but will affect the next * item renderer that opens an editor. * * @default 0 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var editorXOffset:Number = 0; //---------------------------------- // editorYOffset //---------------------------------- //[Inspectable(category=""General"", defaultValue=""0"")] /** * The y location of the upper-left corner of the item editor, * in pixels, relative to the upper-left corner of the item. * This property can be used to make the editor overlap * the item renderer by a few pixels to compensate for a border around the * editor. * Note that changing these values while the editor is displayed * will have no effect on the current editor, but will affect the next * item renderer that opens an editor. * * @default 0 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var editorYOffset:Number = 0; //---------------------------------- // editorUsesEnterKey //---------------------------------- //[Inspectable(category=""General"", defaultValue=""false"")] /** * A flag that indicates whether the item editor uses Enter key. * If true the item editor uses the Enter key and the * AdvancedDataGrid will not look for the Enter key and move the editor in * response. * Note that changing this value while the editor is displayed * will have no effect on the current editor, but will affect the next * item renderer that opens an editor. * * @default false * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public var editorUsesEnterKey:Boolean = false; //---------------------------------- // headerRenderer //---------------------------------- /** * @private * Storage for the headerRenderer property. */ private var _headerRenderer:IFactory; [Bindable(""headerRendererChanged"")] [Inspectable(category=""Other"")] /** * The class factory for item renderer instances that display the * column header for the column. * You can specify a drop-in item renderer, * an inline item renderer, or a custom item renderer component as the * value of this property. * *

The default item renderer is the AdvancedDataGridItemRenderer class, * which displays the item data as text.

* * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ override public function get headerRenderer():IFactory { return _headerRenderer; } /** * @private */ override public function set headerRenderer(value:IFactory):void { _headerRenderer = value; // rebuild the headers /* if (owner) { owner.invalidateList(); owner.columnRendererChanged(this); } dispatchEvent(new Event(""headerRendererChanged"")); */ } //---------------------------------- // headerWordWrap //---------------------------------- /** * @private * Storage for the headerWordWrap property. */ private var _headerWordWrap:*; [Inspectable(category=""Advanced"")] /** * Set to true to wrap the text in the column header * if it does not fit on one line. * If undefined, the AdvancedDataGrid control's wordWrap property * is used. * This property overrides the headerWordWrap property of * the AdvancedDataGrid control. * * @default undefined * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public function get headerWordWrap():* { return _headerWordWrap; } /** * @private */ public function set headerWordWrap(value:*):void { _headerWordWrap = value; /* if (owner) { owner.invalidateList(); } */ } //---------------------------------- // enableIME //---------------------------------- /** * A flag that indicates whether the IME should * be enabled when the component receives focus. * * If an editor is up, it will set enableIME * accordingly. * * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @productversion Flex 4 */ /* public function get enableIME():Boolean { return false; } */ //---------------------------------- // imeMode //---------------------------------- /** * @private * Storage for the imeMode property. */ /* private var _imeMode:String; [Inspectable(category=""Other"")] */ /** * Specifies the IME (input method editor) mode. * The IME mode enables users to enter text in Chinese, Japanese, and Korean. * Flex sets the IME mode when the itemFocusIn event occurs, * and sets it back * to the previous value when the itemFocusOut event occurs. * The flash.system.IMEConversionMode class defines constants for * the valid values for this property. * *

The default value is null, in which case it uses the value of the * AdvancedDataGrid control's imeMode property.

* * @see flash.system.IMEConversionMode * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ /* public function get imeMode():String { return _imeMode; } */ /** * @private */ /* public function set imeMode(value:String):void { _imeMode = value; } */ /* //---------------------------------- // resizable //---------------------------------- [Inspectable(category=""General"")] /!** * Set to true if the user is allowed to resize * the width of the column. * If true, the user can drag the grid lines between * the column headers to resize the column. * * @default true * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 *!/ public var resizable:Boolean = true; //---------------------------------- // showDataTips //---------------------------------- /!** * @private * Storage for the showDataTips property. *!/ private var _showDataTips:*; [Inspectable(category=""Advanced"")] /!** * Set to true to show data tips in the column. * If true, datatips are displayed for text in the rows. Datatips * are tooltips designed to show the text that is too long for the row. * * @default false * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 *!/ public function get showDataTips():* { return _showDataTips; } /!** * @private *!/ public function set showDataTips(value:*):void { _showDataTips = value; /!* if (owner) { owner.invalidateList(); } *!/ } //---------------------------------- // sortable //---------------------------------- [Inspectable(category=""General"")] /!** * Set to true to indicate that the user can click on the * header of this column to sort the data provider. * If this property and the AdvancedDataGrid sortableColumns property * are both true, the AdvancedDataGrid control dispatches a * headerRelease event when a user releases the mouse button * on this column's header. * If no other handler calls the preventDefault() method on * the headerRelease event, the dataField * property or sortCompareFunction in the column is used * to reorder the items in the data provider. * * @default true * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 *!/ public var sortable:Boolean = true; //---------------------------------- // sortCompareFunction //---------------------------------- /!** * @private * Storage for the sortCompareFunction property. *!/ private var _sortCompareFunction:Function; [Bindable(""sortCompareFunctionChanged"")] [Inspectable(category=""Advanced"")] /!** * * A callback function that gets called when sorting the data in * the column. If this property is not specified, the sort tries * to use a basic string or number sort on the data. * If the data is not a string or number or if the dataField * property is not a valid property of the data provider, the sort does * not work or will generate an exception. * If you specify a value of the labelFunction property, * you typically also provide a function to the sortCompareFunction property, * unless sorting is not allowed on this column. * That means you specify a function when the value from the column's dataField * does not sort in the same way as the computed value from the labelFunction property. * *

The AdvancedDataGrid control uses this function to sort the elements of the data * provider collection. The function signature of * the callback function takes two parameters and has the following form:

* *
mySortCompareFunction(obj1:Object, obj2:Object):int 
* *

obj1 — A data element to compare.

* *

obj2 — Another data element to compare with obj1.

* *

The function should return a value based on the comparison * of the objects:

*
    *
  • -1 if obj1 should appear before obj2 in ascending order.
  • *
  • 0 if obj1 = obj2.
  • *
  • 1 if obj1 should appear after obj2 in ascending order.
  • *
* *

Note: The obj1 and * obj2 parameters are entire data provider elements and not * just the data for the item.

* * @default null * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 *!/ public function get sortCompareFunction():Function { return _sortCompareFunction; } /!** * @private *!/ public function set sortCompareFunction(value:Function):void { _sortCompareFunction = value; // dispatchEvent(new Event(""sortCompareFunctionChanged"")); } */ //---------------------------------- // sortCompareType //---------------------------------- /** * @private */ //private var _sortCompareType:String; /** * @inheritDoc * * @langversion 3.0 * @playerversion Flash 11.8 * @playerversion AIR 3.8 * @productversion Flex 4.11 */ /* [Bindable(""sortCompareTypeChanged"")] public function get sortCompareType():String { return _sortCompareType; } */ /** * @private */ /* public function set sortCompareType(value:String):void { if (_sortCompareType != value) { _sortCompareType = value; dispatchEvent(new Event(""sortCompareTypeChanged"")); } } */ /* //---------------------------------- // visible //---------------------------------- /!** * @private * Storage for the visible property. *!/ private var _visible:Boolean = true; [Inspectable(category=""General"", defaultValue=""true"")] /!** * If true, the column is visible. * Set to false to hide the column. * * @default true * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 *!/ public function get visible():Boolean { return _visible; } /!** * @private *!/ public function set visible(value:Boolean):void { if (_visible != value) { _visible = value; if (owner) { (owner as AdvancedDataGrid).columnsInvalid(); // columns invisible at init don't get a dataprovider so // force assignment by faking a dp change (owner as AdvancedDataGrid).model.dispatchEvent(new Event(""dataProviderChanged"")); //owner.invalidateProperties(); //owner.invalidateSize(); //owner.invalidateList(); } } }*/ //---------------------------------- // styleFunction //---------------------------------- /** * @private */ private var _styleFunction:Function; /** * A callback function that is called when rendering each cell. * The signature of the function should be: * *
function myStyleFunction(data:Object, column:AdvancedDataGridColumn):Object
* *

data - data object associated with the item being rendered.

*

column - AdvancedDataGridColumn instance with * which the item renderer is associated.

* *

The return value should be a object with styles as properties * having the required values. * For example:

* *
{ color:0xFF0000, fontWeight:""bold"" }
* * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public function get styleFunction():Function { return _styleFunction; } /** * @private */ public function set styleFunction(value:Function):void { _styleFunction = value; /* if (owner) owner.invalidateDisplayList(); */ } //---------------------------------- // formatter //---------------------------------- /** * @private */ //private var _formatter:IFormatter; /** * An instance of a subclasses of mx.formatters.Formatter. * The control use this class to format the column text. * * @default null * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ /* public function get formatter():IFormatter { return _formatter; } */ /** * @private */ /* public function set formatter(value:IFormatter):void { _formatter = value; if (owner) owner.invalidateDisplayList(); } */ //-------------------------------------------------------------------------- // // Overridden methods // //-------------------------------------------------------------------------- /** * @private */ /* override mx_internal function addStyleToProtoChain( chain:Object, target:DisplayObject, filterMap:Object = null):Object { var parentGrid:AdvancedDataGridBaseEx = owner; var item:IListItemRenderer = IListItemRenderer(target); chain = super.addStyleToProtoChain(chain, target); // If the target data is a AdvancedDataGridColumn and has a data // field in its data, then it is a header so add the // AdvancedDataGrid.headerStyleName object to the head of the proto chain. if (item.data && (item.data is AdvancedDataGridColumn)) { var s:Object; var headerStyleName:Object = parentGrid.getStyle(""headerStyleName""); if (headerStyleName) { if (headerStyleName is String) { chain = addStylesToProtoChain(String(headerStyleName), chain, target); } if (headerStyleName is CSSStyleDeclaration) chain = headerStyleName.addStyleToProtoChain(chain, target); } headerStyleName = getStyle(""headerStyleName""); if (headerStyleName) { if (headerStyleName is String) { chain = addStylesToProtoChain(String(headerStyleName), chain, target); } if (headerStyleName is CSSStyleDeclaration) chain = headerStyleName.addStyleToProtoChain(chain, target); } } // save the current font context if (!fontPropertiesSet) { fontPropertiesSet = true; saveFontContext(owner ? owner.moduleFactory : null); } return chain; } */ /** * @private */ /* override public function setStyle(styleProp:String, value:*):void { fontPropertiesSet = false; var oldValue:Object = getStyle(styleProp); var regenerate:Boolean = false; // If this AdvancedDataGridColumn didn't previously have a factory, defaultFactory, or // overrides object, then this AdvancedDataGridColumn hasn't been added to the item // renderers proto chains. In that case, we need to regenerate all the item // renderers proto chains. if (factory == null && defaultFactory == null && !overrides && (oldValue !== value)) // must be !== { regenerate = true; } super.setLocalStyle(styleProp, value); // The default implementation of setStyle won't always regenerate // the proto chain when headerStyleName is set, and we need to make sure // that they are regenerated if (styleProp == ""headerStyleName"") { if (owner) { owner.regenerateStyleCache(true); owner.notifyStyleChangeInChildren(""headerStyleName"", true); } return; } if (owner) { if (regenerate) { owner.regenerateStyleCache(true); } if (hasFontContextChanged(owner.moduleFactory)) { owner.columnRendererChanged(this); } owner.invalidateList(); } } */ /** * @private */ /* override public function get specificity():int { // Return 10 as there is a sorting mechanism based on specificity now // and there could be ancestor specificity also!! return 10; } */ //-------------------------------------------------------------------------- // // Methods // //-------------------------------------------------------------------------- /** * @private * Internal function to allow the AdvancedDataGrid to set the width of the * column without locking it as an explicitWidth mx_internal function setWidth(value:Number):void { _width = value; } */ /** * @private * * Apply column's Formatter if present. * */ /* private function applyFormatting(data:String):String { if (formatter != null && data != null) { var label:String = formatter.format(data); // Silently ignore formatter errors. For example, errors occur when // the property corresponding to the dataField is not present in the // row object i.e. it'll be empty and it's not anybody's fault that // it's an error. const mxFormatter:Formatter = formatter as Formatter; if (mxFormatter && mxFormatter.error) return null; return label; } else { return data; } } */ /** * Returns the String that the item renderer displays for the given data object. * If the AdvancedDataGridColumn or its AdvancedDataGrid control * has a non-null labelFunction * property, it applies the function to the data object. * Otherwise, the method extracts the contents of the field specified by the * dataField property, or gets the string value of the data object. * If the method cannot convert the parameter to a String, it returns a * single space. * * @param data Object to be rendered. * * @param withFormatting It true specifies to return * the String with any formatting applied to it. * * @return Displayable String based on the data. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ /* public function itemToLabel(data:Object, withFormatting:Boolean=true):String { var label:String = itemToLabelWithoutFormatting(data); if (withFormatting) return applyFormatting(label); return label; } */ /** * @private * * This is the original AdvancedDataGrid.itemToLabel() that has been wrapped with applyFormatting() * */ /* private function itemToLabelWithoutFormatting(data:Object):String { var headerInfo:AdvancedDataGridHeaderInfo = owner.mx_internal::getHeaderInfo(this); // In case of Column grouping, when a column has a parent with dataField/labelFunction set, this column is // supposed to take value from what its parent supplies it if (headerInfo != null && headerInfo.internalLabelFunction != null) data = headerInfo.internalLabelFunction(data, this); if (!data) return "" ""; if (labelFunction != null) return labelFunction(data, this); if (owner.labelFunction != null) return owner.labelFunction(data, this); if (typeof(data) == ""object"" || typeof(data) == ""xml"") { if (dataField != null && dataField in data) data = data[dataField]; else return "" ""; // stops ""[object Object]"" showing } if (data is String) return String(data); try { return data.toString(); } catch(e:Error) { } return "" ""; } */ /** * Returns a String that the item renderer displays as the data tip for the given data object, * based on the dataTipField and dataTipFunction properties. * If the method cannot convert the parameter to a String, it returns a * single space. * *

This method is for use by developers who are creating subclasses * of the AdvancedDataGridColumn class. * It is not for use by application developers.

* * @param data Object to be rendered. * * @return Displayable String based on the data. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ /* public function itemToDataTip(data:Object):String { if (dataTipFunction != null) return dataTipFunction(data); if (owner.dataTipFunction != null) return owner.dataTipFunction(data); // for header items, return the header text if (data is AdvancedDataGridColumn) return AdvancedDataGridColumn(data).headerText; if (typeof(data) == ""object"" || typeof(data) == ""xml"") { var field:String = dataTipField; if (!field) field = owner.dataTipField; if (field != null) { if (field in data && data[field] != null) data = data[field]; } else if (dataField != null) { if (dataField in data && data[dataField] != null) data = data[dataField]; else data = null; } } if (data is String) return String(data); try { return data.toString(); } catch(e:Error) { } return "" ""; } */ /** * @private * * Save the current font context to member fields. */ /* private function saveFontContext(flexModuleFactory:IFlexModuleFactory):void { // Save for hasFontContextChanged() hasFontContextBeenSaved = true; var fontName:String = StringUtil.trimArrayElements(getStyle(""fontFamily""), "",""); var fontWeight:String = getStyle(""fontWeight""); var fontStyle:String = getStyle(""fontStyle""); var bold:Boolean = fontWeight == ""bold""; var italic:Boolean = fontStyle == ""italic""; oldEmbeddedFontContext = (noEmbeddedFonts || !embeddedFontRegistry) ? null : embeddedFontRegistry.getAssociatedModuleFactory( fontName, bold, italic, this, flexModuleFactory, owner.systemManager); } */ /** * @private * Test if the current font context has changed * since that last time saveFontContext() was called. */ /* mx_internal function hasFontContextChanged( flexModuleFactory:IFlexModuleFactory):Boolean { // If the font has not been saved yet, then return false, // the font context has not changed. if (!hasFontContextBeenSaved) return false; var fontName:String = StringUtil.trimArrayElements(getStyle(""fontFamily""), "",""); var fontWeight:String = getStyle(""fontWeight""); var fontStyle:String = getStyle(""fontStyle""); // Check if the module factory has changed. var bold:Boolean = fontWeight == ""bold""; var italic:Boolean = fontStyle == ""italic""; var fontContext:IFlexModuleFactory = (noEmbeddedFonts || !embeddedFontRegistry) ? null : embeddedFontRegistry.getAssociatedModuleFactory( fontName, bold, italic, this, flexModuleFactory, owner.systemManager); return fontContext != oldEmbeddedFontContext; } */ /** * @private */ /* private function addStylesToProtoChain(styles:String, chain:Object, target:DisplayObject):Object { var styleNames:Array = styles.split(/\\s+/); for (var c:int=0; c < styleNames.length; c++) { if (styleNames[c].length) { var declaration:CSSStyleDeclaration = owner.styleManager.getMergedStyleDeclaration(""."" + styleNames[c]); if (declaration) chain = declaration.addStyleToProtoChain(chain, target); } } return chain; } */ /** * @private * * Sets the properties of this Object to the given column. * * It sets only the required properties. * * @param col AdvancedDataGridColumn in which the properties are to be set. * */ /* protected function copyProperties(col:AdvancedDataGridColumn):void { // copy properties col.defaultFactory = this.defaultFactory; col.editable = this.editable; col.editorDataField = this.editorDataField; col.editorHeightOffset = this.editorHeightOffset; col.editorUsesEnterKey = this.editorUsesEnterKey; col.editorWidthOffset = this.editorWidthOffset; col.editorXOffset = this.editorXOffset; col.editorYOffset = this.editorYOffset; col.factory = this.factory; col.itemEditor = this.itemEditor; col.rendererIsEditor = this.rendererIsEditor; col.resizable = this.resizable; col.sortable = this.sortable; col.sortDescending = this.sortDescending; col.dataField = this.dataField; col.dataTipField = this.dataTipField; col.dataTipFunction = this.dataTipFunction; col.formatter = this.formatter; col.headerRenderer = this.headerRenderer; col.headerText = this.headerText; col.headerWordWrap = this.headerWordWrap; col.imeMode = this.imeMode; col.itemRenderer = this.itemRenderer; col.labelFunction = this.labelFunction; col.minWidth = this.minWidth; col.showDataTips = this.showDataTips; col.sortCompareFunction = this.sortCompareFunction; col.styleFunction = this.styleFunction; col.visible = this.visible; col.width = this.width; col.wordWrap = this.wordWrap; // copy styles col.public::setStyle(""backgroundColor"",this.getStyle(""backgroundColor"")); col.public::setStyle(""headerStyleName"",this.getStyle(""headerStyleName"")); col.public::setStyle(""paddingLeft"",this.getStyle(""paddingLeft"")); col.public::setStyle(""paddingRight"",this.getStyle(""paddingRight"")); // copy text styles col.public::setStyle(""color"",this.getStyle(""color"")); col.public::setStyle(""disabledColor"",this.getStyle(""disabledColor"")); col.public::setStyle(""fontAntiAliasType"",this.getStyle(""fontAntiAliasType"")); col.public::setStyle(""fontFamily"",this.getStyle(""fontFamily"")); col.public::setStyle(""fontGridFitType"",this.getStyle(""fontGridFitType"")); col.public::setStyle(""fontSharpness"",this.getStyle(""fontSharpness"")); col.public::setStyle(""fontSize"",this.getStyle(""fontSize"")); col.public::setStyle(""fontStyle"",this.getStyle(""fontStyle"")); col.public::setStyle(""fontThickness"",this.getStyle(""fontThickness"")); col.public::setStyle(""fontWeight"",this.getStyle(""fontWeight"")); col.public::setStyle(""kerning"",this.getStyle(""kerning"")); col.public::setStyle(""letterSpacing"",this.getStyle(""letterSpacing"")); col.public::setStyle(""textAlign"",this.getStyle(""textAlign"")); col.public::setStyle(""textDecoration"",this.getStyle(""textDecoration"")); col.public::setStyle(""textIndent"",this.getStyle(""textIndent"")); } */ /** * * Clone this column and return a new Column with the * same properties and styles as this one. * * It does not set all the available properties * * @return col AdvancedDataGridColumn. * * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Royale 0.9.3 */ public function clone():AdvancedDataGridColumn { // make a new column var col:AdvancedDataGridColumn = new AdvancedDataGridColumn(); // copy the properties //copyProperties(col); return col; } } } ",12386,True,2654.6651581336637,median "/* ClipWindow.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8g2lib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1306_72X40_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_WS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_KS0713_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_KS0713_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7567_HEM6432_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_IST7920_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_IST7920_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_DEM240064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1617_JLX128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1617_JLX128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list void setup(void) { /* U8g2 Project: SSD1306 Test Board */ //pinMode(10, OUTPUT); //pinMode(9, OUTPUT); //digitalWrite(10, 0); //digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); /* U8g2 Project: LC7981 Test Board, connect RW to GND */ //pinMode(17, OUTPUT); //digitalWrite(17, 0); /* U8g2 Project: Pax Instruments Shield: Enable Backlight */ //pinMode(6, OUTPUT); //digitalWrite(6, 0); u8g2.begin(); } u8g2_uint_t x = 0; void loop(void) { if ( x == 0 ) x = 40; else x--; u8g2.setFont(u8g2_font_ncenB10_tr); u8g2.firstPage(); do { /* assign a clip window and draw some text into it */ u8g2.setClipWindow(35, 11, 74, 27); /* upper left and lower right position */ u8g2.drawStr(x,23,""U8g2 U8g2""); /* remove clip window, draw to complete screen */ u8g2.setMaxClipWindow(); u8g2.drawFrame(34, 10, 40, 18); } while ( u8g2.nextPage() ); delay(10); } ",16146,True,4928.098121370338,median "/* UpdateArea.ino Demonstration for the UpdateDisplayArea command Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8g2lib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Frame Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_3W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_F_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1306_72X40_ER_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" OLED //U8G2_SSD1322_NHD_256X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_MIDAS_128X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_WS_128X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_F_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_F_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_F u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_F u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_F_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_F_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7565_EA_DOGM128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_KS0713_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_KS0713_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_LX12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7567_HEM6432_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_F_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_F_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_F_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_IST7920_128X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_IST7920_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_LC7981_160X80_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_F u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FG with GND //U8G2_SED1330_240X128_F_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // A0 is dc pin! //U8G2_RA8835_NHD_240X128_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1604_JLX19264_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_DEM240064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_F_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_F_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, DOGXL240 Test Board //U8G2_UC1611_EW50850_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1617_JLX128128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1617_JLX128128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1638_160X128_F_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_MAX7219_64X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); //U8G2_MAX7219_32X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); //U8G2_MAX7219_8X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); //U8G2_LS013B7DH03_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_F_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list int16_t offset; // current offset for the scrolling text u8g2_uint_t width; // pixel width of the scrolling text (must be lesser than 128 unless U8G2_16BIT is defined const char *text = ""U8g2""; // scroll this text from right to left const uint8_t tile_area_x_pos = 2; // Update area left position (in tiles) const uint8_t tile_area_y_pos = 3; // Update area upper position (distance from top in tiles) const uint8_t tile_area_width = 12; const uint8_t tile_area_height = 3; // this will allow cour18 chars to fit into the area const u8g2_uint_t pixel_area_x_pos = tile_area_x_pos*8; const u8g2_uint_t pixel_area_y_pos = tile_area_y_pos*8; const u8g2_uint_t pixel_area_width = tile_area_width*8; const u8g2_uint_t pixel_area_height = tile_area_height*8; void setup(void) { u8g2.begin(); u8g2.clearBuffer(); // clear the internal memory u8g2.setFont(u8g2_font_helvR10_tr); // choose a suitable font u8g2.drawStr(0,12,""UpdateDisplayArea""); // write something to the internal memory // draw a frame, only the content within the frame will be updated // the frame is never drawn again, but will stay on the display u8g2.drawBox(pixel_area_x_pos-1, pixel_area_y_pos-1, pixel_area_width+2, pixel_area_height+2); u8g2.sendBuffer(); // transfer internal memory to the display u8g2.setFont(u8g2_font_courB18_tr); // set the target font for the text width calculation width = u8g2.getUTF8Width(text); // calculate the pixel width of the text offset = width+pixel_area_width; } void loop(void) { u8g2.clearBuffer(); // clear the complete internal memory // draw the scrolling text at current offset u8g2.setFont(u8g2_font_courB18_tr); // set the target font u8g2.drawUTF8( pixel_area_x_pos-width+offset, pixel_area_y_pos+pixel_area_height+u8g2.getDescent()-1, text); // draw the scolling text // now only update the selected area, the rest of the display content is not changed u8g2.updateDisplayArea(tile_area_x_pos, tile_area_y_pos, tile_area_width, tile_area_height); offset--; // scroll by one pixel if ( offset == 0 ) offset = width+pixel_area_width; // start over again delay(10); // do some small delay } ",16215,True,4869.599222284706,median "/* Clock.ino Demonstrates a clock-like display with a very huge font. Also shows usage of u8x8_u8toa(). Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8g2lib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1306_72X40_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_WS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_KS0713_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_KS0713_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7567_HEM6432_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_IST7920_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_IST7920_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_DEM240064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1617_JLX128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1617_JLX128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list void setup(void) { /* U8g2 Project: SSD1306 Test Board */ //pinMode(10, OUTPUT); //pinMode(9, OUTPUT); //digitalWrite(10, 0); //digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); /* U8g2 Project: LC7981 Test Board, connect RW to GND */ //pinMode(17, OUTPUT); //digitalWrite(17, 0); /* U8g2 Project: Pax Instruments Shield: Enable Backlight */ //pinMode(6, OUTPUT); //digitalWrite(6, 0); u8g2.begin(); } uint8_t m = 24; void loop(void) { char m_str[3]; strcpy(m_str, u8x8_u8toa(m, 2)); /* convert m to a string with two digits */ u8g2.firstPage(); do { u8g2.setFont(u8g2_font_logisoso62_tn); u8g2.drawStr(0,63,""9""); u8g2.drawStr(33,63,"":""); u8g2.drawStr(50,63,m_str); } while ( u8g2.nextPage() ); delay(1000); m++; if ( m == 60 ) m = 0; } ",16138,True,5020.86932063554,median "// GxEPD2_MultiDisplayExample : Display Library example for SPI e-paper panels from Dalian Good Display and boards from Waveshare. // Requires HW SPI and Adafruit_GFX. Caution: the e-paper panels require 3.3V supply AND data lines! // // Display Library based on Demo Example from Good Display: http://www.e-paper-display.com/download_list/downloadcategoryid=34&isMode=false.html // // Author: Jean-Marc Zingg // // Version: see library.properties // // Library: https://github.com/ZinggJM/GxEPD2 // Supporting Arduino Forum Topics: // Waveshare e-paper displays with SPI: http://forum.arduino.cc/index.php?topic=487007.0 // Good Display ePaper for Arduino: https://forum.arduino.cc/index.php?topic=436411.0 // mapping suggestion from Waveshare SPI e-Paper to Wemos D1 mini // BUSY -> D2, RST -> D4, DC -> D3, CS -> D8, CLK -> D5, DIN -> D7, GND -> GND, 3.3V -> 3.3V // NOTE: connect 3.3k pull-down from D8 to GND if your board or shield has level converters // NOTE for ESP8266: using SS (GPIO15) for CS may cause boot mode problems, use different pin in case, or 4k7 pull-down // mapping suggestion from Waveshare SPI e-Paper to generic ESP8266 // BUSY -> GPIO4, RST -> GPIO2, DC -> GPIO0, CS -> GPIO15, CLK -> GPIO14, DIN -> GPIO13, GND -> GND, 3.3V -> 3.3V // NOTE: connect 3.3k pull-down from GPIO15 to GND if your board or shield has level converters // NOTE for ESP8266: using SS (GPIO15) for CS may cause boot mode problems, use different pin in case, or 3.3k pull-down // mapping of Waveshare e-Paper ESP8266 Driver Board, new version (see GxEPD2_boards_added.h for old version) // BUSY -> GPIO5, RST -> GPIO2, DC -> GPIO4, CS -> GPIO15, CLK -> GPIO14, DIN -> GPIO13, GND -> GND, 3.3V -> 3.3V // NOTE for ESP8266: using SS (GPIO15) for CS may cause boot mode problems, add a 3.3k pull-down in case // the e-Paper ESP8266 Driver Board should have no boot mode issue, as it doesn't use level converters // mapping suggestion for ESP32, e.g. LOLIN32, see .../variants/.../pins_arduino.h for your board // NOTE: there are variants with different pins for SPI ! CHECK SPI PINS OF YOUR BOARD // BUSY -> 4, RST -> 16, DC -> 17, CS -> SS(5), CLK -> SCK(18), DIN -> MOSI(23), GND -> GND, 3.3V -> 3.3V // mapping of Waveshare ESP32 Driver Board // BUSY -> 25, RST -> 26, DC -> 27, CS-> 15, CLK -> 13, DIN -> 14 // NOTE: this board uses ""unusual"" SPI pins and requires re-mapping of HW SPI to these pins in SPIClass // see example GxEPD2_WS_ESP32_Driver.ino, it shows how this can be done easily // new mapping suggestion for STM32F1, e.g. STM32F103C8T6 ""BluePill"" // BUSY -> A1, RST -> A2, DC -> A3, CS-> A4, CLK -> A5, DIN -> A7 // mapping suggestion for AVR, UNO, NANO etc. // BUSY -> 7, RST -> 9, DC -> 8, CS-> 10, CLK -> 13, DIN -> 11 // base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter // enable GxEPD2_GFX base class #define ENABLE_GxEPD2_GFX 1 // uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX //#include // Note: if you use this with ENABLE_GxEPD2_GFX 1: // uncomment it in GxEPD2_GFX.h too, or add #include before any #include // !!!! ============================================================================================ !!!! #include #include #include // create display class instances for each display, each instance with different CS line, each instance with RST disabled, // (or use separate RST pins for each display), // each instance with different BUSY line, or BUSY lines or-ed to one pin // disable reset line to disable cross resets by multiple instances #if defined (ESP8266) #define RST_PIN 0 // D3(0) #define CS_1 SS // CS = D8(15) #define CS_2 16 // CS = D0(16) #define CS_3 5 // CS = D1(5) // BUSY lines can be or-ed with diodes and pulldown register for displays with BUSY active HIGH #define BUSY_H_x 4 // BUSY = D2(4) // BUSY lines can be or-ed with diodes and pullup resistor for displays with BUSY active LOW //#define BUSY_L_x 4 // BUSY = D2(4) // select one and adapt to your mapping, can use full buffer size (full HEIGHT) //GxEPD2_BW display1(GxEPD2_154(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEP015OC1 no longer available GxEPD2_BW display1(GxEPD2_154_D67(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEH0154D67 //GxEPD2_BW display(GxEPD2_154_T8(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0154T8 152x152 //GxEPD2_BW display(GxEPD2_154_M09(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0154M09 200x200 //GxEPD2_BW display(GxEPD2_154_M10(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0154M10 152x152 GxEPD2_BW display2(GxEPD2_213(/*CS=*/ CS_2, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); //GxEPD2_BW display(GxEPD2_213_B72(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEH0213B72 //GxEPD2_BW display(GxEPD2_213_B73(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEH0213B73 //GxEPD2_BW display(GxEPD2_213_flex(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0213I5F //GxEPD2_BW display(GxEPD2_213_M21(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0213M21 //GxEPD2_BW display(GxEPD2_213_T5D(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0213T5D GxEPD2_BW display3(GxEPD2_290(/*CS=*/ CS_3, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); //GxEPD2_BW display(GxEPD2_290_T5(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW029T5 //GxEPD2_BW display(GxEPD2_290_T5D(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW029T5D //GxEPD2_BW display(GxEPD2_290_M06(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW029M06 //GxEPD2_BW display(GxEPD2_260(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_BW display(GxEPD2_270(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_BW display(GxEPD2_371(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_BW display(GxEPD2_420(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_BW display(GxEPD2_420_M01(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW042M01 // can use only half buffer size //GxEPD2_BW < GxEPD2_583, GxEPD2_583::HEIGHT / 2 > display(GxEPD2_583(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_BW < GxEPD2_583_T8, GxEPD2_583_T8::HEIGHT / 2 > display(GxEPD2_583_T8(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_BW < GxEPD2_750, GxEPD2_750::HEIGHT / 2 > display(GxEPD2_750(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_BW < GxEPD2_750_T7, GxEPD2_750_T7::HEIGHT / 2 > display(GxEPD2_750_T7(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW075T7 800x480 // 3-color e-papers //GxEPD2_3C display(GxEPD2_154c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW0154Z04 no longer available //GxEPD2_3C display(GxEPD2_154_Z90c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEH0154Z90 //GxEPD2_3C display(GxEPD2_213c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_3C display(GxEPD2_213_Z19c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW0213Z19 //GxEPD2_3C display(GxEPD2_290c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_3C display(GxEPD2_290_Z13c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEH029Z13 //GxEPD2_3C display(GxEPD2_290_C90c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEM029C90 //GxEPD2_3C display(GxEPD2_270c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // can use only half buffer size //GxEPD2_3C display(GxEPD2_420c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // can use only quarter buffer size //GxEPD2_3C display(GxEPD2_583c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_3C display3(GxEPD2_750c(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_3C < GxEPD2_750c_Z08, GxEPD2_750c_Z08::HEIGHT / 4 > display(GxEPD2_750c_Z08(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW075Z08 800x480 #endif #if defined(ESP32) #define RST_PIN 16 #define CS_1 SS // CS = 5(SS) #define CS_2 0 // CS = 0 #define CS_3 2 // CS = 2 #define CS_4 13 // CS = 13 // BUSY lines can be or-ed with diodes and pulldown register for displays with BUSY active HIGH #define BUSY_H_x 4 // BUSY = 4 // BUSY lines can be or-ed with diodes and pullup resistor for displays with BUSY active LOW #define BUSY_L_x 15 // BUSY = 15 // select one and adapt to your mapping, can use full buffer size (full HEIGHT) //GxEPD2_BW display1(GxEPD2_154(/*CS=*/ CS_1, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEP015OC1 no longer available GxEPD2_BW display1(GxEPD2_154_D67(/*CS=*/ CS_1, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEH0154D67 //GxEPD2_BW display(GxEPD2_154_T8(/*CS=*/ CS_1, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0154T8 152x152 //GxEPD2_BW display(GxEPD2_154_M09(/*CS=*/ CS_1, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0154M09 200x200 //GxEPD2_BW display(GxEPD2_154_M10(/*CS=*/ CS_1, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0154M10 152x152 GxEPD2_BW display2(GxEPD2_213(/*CS=*/ CS_2, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); //GxEPD2_BW display(GxEPD2_213_B72(/*CS=*/ CS_2, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEH0213B72 //GxEPD2_BW display(GxEPD2_213_B73(/*CS=*/ CS_2, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEH0213B73 //GxEPD2_BW display(GxEPD2_213_flex(/*CS=*/ CS_2, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0213I5F //GxEPD2_BW display(GxEPD2_213_M21(/*CS=*/ CS_2, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0213M21 //GxEPD2_BW display(GxEPD2_213_T5D(//*CS=*/ CS_2, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW0213T5D GxEPD2_BW display3(GxEPD2_290(/*CS=*/ CS_3, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); //GxEPD2_BW display(GxEPD2_290_T5(/*CS=*/ CS_1, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW029T5 //GxEPD2_BW display(GxEPD2_290_T5D(/*CS=*/ CS_2, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW029T5D //GxEPD2_BW display(GxEPD2_290_M06(/*CS=*/ CS_2, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_H_x)); // GDEW029M06 //GxEPD2_BW display(GxEPD2_260(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_BW display(GxEPD2_270(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_BW display(GxEPD2_371(/*CS=*/ CS_x, /*DC=D3*/ 0, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_BW display4(GxEPD2_420(/*CS=*/ CS_4, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_BW display(GxEPD2_420_M01(/*CS=*/ CS_4, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW042M01 //GxEPD2_BW display(GxEPD2_583(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_BW display(GxEPD2_583_T8(/*CS=5*/ SS, /*DC=*/ 17, /*RST=*/ 16, /*BUSY=*/ 4)); //GxEPD2_BW display(GxEPD2_750(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_BW display(GxEPD2_750_T7(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW075T7 800x480 // 3-color e-papers //GxEPD2_3C display(GxEPD2_154c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW0154Z04 no longer available //GxEPD2_3C display(GxEPD2_154_Z90c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEH0154Z90 //GxEPD2_3C display(GxEPD2_213c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_3C display(GxEPD2_213_Z19c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW0213Z19 //GxEPD2_3C display(GxEPD2_290c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_3C display(GxEPD2_290_Z13c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEH029Z13 //GxEPD2_3C display(GxEPD2_290_C90c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEM029C90 //GxEPD2_3C display(GxEPD2_270c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_3C display(GxEPD2_420c(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); GxEPD2_3C display4(GxEPD2_750c(/*CS=*/ CS_4, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); //GxEPD2_3C display(GxEPD2_750c_Z08(/*CS=*/ CS_x, /*DC=*/ 17, /*RST=*/ -1, /*BUSY=*/ BUSY_L_x)); // GDEW075Z08 800x480 #endif // comment out unused bitmaps to reduce code space used #include ""bitmaps/Bitmaps200x200.h"" // 1.54"" b/w #include ""bitmaps/Bitmaps128x250.h"" // 2.13"" b/w #include ""bitmaps/Bitmaps128x296.h"" // 2.9"" b/w #include ""bitmaps/Bitmaps176x264.h"" // 2.7"" b/w #include ""bitmaps/Bitmaps400x300.h"" // 4.2"" b/w #include ""bitmaps/Bitmaps640x384.h"" // 7.5"" b/w // 3-color #include ""bitmaps/Bitmaps3c200x200.h"" // 1.54"" b/w/r #include ""bitmaps/Bitmaps3c104x212.h"" // 2.13"" b/w/r #include ""bitmaps/Bitmaps3c128x296.h"" // 2.9"" b/w/r #include ""bitmaps/Bitmaps3c176x264.h"" // 2.7"" b/w/r #include ""bitmaps/Bitmaps3c400x300.h"" // 4.2"" b/w/r void setup() { Serial.begin(115200); Serial.println(); Serial.println(""setup""); // one common reset for all displays digitalWrite(RST_PIN, HIGH); pinMode(RST_PIN, OUTPUT); delay(20); digitalWrite(RST_PIN, LOW); delay(20); digitalWrite(RST_PIN, HIGH); delay(200); display1.init(115200); // enable diagnostic output on Serial display2.init(115200); // enable diagnostic output on Serial display3.init(115200); // enable diagnostic output on Serial #if defined(ESP32) display4.init(115200); // enable diagnostic output on Serial #endif // first update should be full refresh helloWorld(display1); helloWorld(display2); helloWorld(display3); #if defined(ESP32) helloWorld(display4); #endif delay(1000); // partial refresh mode can be used to full screen, // effective if display panel hasFastPartialUpdate helloFullScreenPartialMode(display1); helloFullScreenPartialMode(display2); helloFullScreenPartialMode(display3); #if defined(ESP32) helloFullScreenPartialMode(display4); #endif delay(1000); helloArduino(display1); helloArduino(display2); helloArduino(display3); #if defined(ESP32) helloArduino(display4); #endif delay(1000); helloEpaper(display1); helloEpaper(display2); helloEpaper(display3); #if defined(ESP32) helloEpaper(display4); #endif delay(1000); showFont(display1, ""FreeMonoBold9pt7b"", &FreeMonoBold9pt7b); showFont(display2, ""FreeMonoBold9pt7b"", &FreeMonoBold9pt7b); showFont(display3, ""FreeMonoBold9pt7b"", &FreeMonoBold9pt7b); #if defined(ESP32) showFont(display4, ""FreeMonoBold9pt7b"", &FreeMonoBold9pt7b); #endif delay(1000); drawBitmaps(display1); drawBitmaps(display2); drawBitmaps(display3); #if defined(ESP32) drawBitmaps(display4); #endif // if (display1.epd2.hasPartialUpdate) // { // showPartialUpdate(display1); // delay(1000); // } // else // on GDEW0154Z04 only full update available, doesn't look nice //drawCornerTest(display1); //showBox(display1, 16, 16, 48, 32, false); //showBox(display1, 16, 56, 48, 32, true); display1.powerOff(); display2.powerOff(); display3.powerOff(); Serial.println(""setup done""); } void loop() { } void helloWorld(GxEPD2_GFX& display) { //Serial.println(""helloWorld""); display.setRotation(1); display.setFont(&FreeMonoBold9pt7b); display.setTextColor(GxEPD_BLACK); uint16_t x = (display.width() - 160) / 2; uint16_t y = display.height() / 2; display.setFullWindow(); display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.setCursor(x, y); display.println(""Hello World!""); } while (display.nextPage()); //Serial.println(""helloWorld done""); } void helloFullScreenPartialMode(GxEPD2_GFX& display) { //Serial.println(""helloFullScreenPartialMode""); display.setPartialWindow(0, 0, display.width(), display.height()); display.setRotation(1); display.setFont(&FreeMonoBold9pt7b); display.setTextColor(GxEPD_BLACK); display.firstPage(); do { uint16_t x = (display.width() - 160) / 2; uint16_t y = display.height() / 2; display.fillScreen(GxEPD_WHITE); display.setCursor(x, y); display.println(""Hello World!""); y = display.height() / 4; display.setCursor(x, y); display.println(""full screen""); y = display.height() * 3 / 4; if (display.width() <= 200) x = 0; display.setCursor(x, y); if (display.epd2.hasFastPartialUpdate) { display.println(""fast partial mode""); } else if (display.epd2.hasPartialUpdate) { display.println(""slow partial mode""); } else { display.println(""no partial mode""); } } while (display.nextPage()); //Serial.println(""helloFullScreenPartialMode done""); } void helloArduino(GxEPD2_GFX& display) { //Serial.println(""helloArduino""); display.setRotation(1); display.setFont(&FreeMonoBold9pt7b); display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK); uint16_t x = (display.width() - 160) / 2; uint16_t y = display.height() / 4; display.setPartialWindow(0, y - 14, display.width(), 20); display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.setCursor(x, y); display.println(""Hello Arduino!""); } while (display.nextPage()); delay(1000); //Serial.println(""helloArduino done""); } void helloEpaper(GxEPD2_GFX& display) { //Serial.println(""helloEpaper""); display.setRotation(1); display.setFont(&FreeMonoBold9pt7b); display.setTextColor(display.epd2.hasColor ? GxEPD_RED : GxEPD_BLACK); uint16_t x = (display.width() - 160) / 2; uint16_t y = display.height() * 3 / 4; display.setPartialWindow(0, y - 14, display.width(), 20); display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.setCursor(x, y); display.println(""Hello E-Paper!""); } while (display.nextPage()); //Serial.println(""helloEpaper done""); } void showBox(GxEPD2_GFX& display, uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial) { //Serial.println(""showBox""); display.setRotation(1); if (partial) { display.setPartialWindow(x, y, w, h); } else { display.setFullWindow(); } display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.fillRect(x, y, w, h, GxEPD_BLACK); } while (display.nextPage()); //Serial.println(""showBox done""); } void drawCornerTest(GxEPD2_GFX& display) { display.setFullWindow(); display.setFont(&FreeMonoBold9pt7b); display.setTextColor(GxEPD_BLACK); for (uint16_t r = 0; r <= 4; r++) { display.setRotation(r); display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.fillRect(0, 0, 8, 8, GxEPD_BLACK); display.fillRect(display.width() - 18, 0, 16, 16, GxEPD_BLACK); display.fillRect(display.width() - 25, display.height() - 25, 24, 24, GxEPD_BLACK); display.fillRect(0, display.height() - 33, 32, 32, GxEPD_BLACK); display.setCursor(display.width() / 2, display.height() / 2); display.print(display.getRotation()); } while (display.nextPage()); delay(2000); } } void showFont(GxEPD2_GFX& display, const char name[], const GFXfont* f) { display.setFullWindow(); display.setRotation(0); display.setTextColor(GxEPD_BLACK); display.firstPage(); do { drawFont(display, name, f); } while (display.nextPage()); } //void drawFont(GxEPD2_GFX& display, const char name[], const GFXfont* f); void drawFont(GxEPD2_GFX& display, const char name[], const GFXfont* f) { //display.setRotation(0); display.fillScreen(GxEPD_WHITE); display.setTextColor(GxEPD_BLACK); display.setFont(f); display.setCursor(0, 0); display.println(); display.println(name); display.println("" !\\""#$%&'()*+,-./""); display.println(""0123456789:;<=>?""); display.println(""@ABCDEFGHIJKLMNO""); display.println(""PQRSTUVWXYZ[\\\\]^_""); if (display.epd2.hasColor) { display.setTextColor(GxEPD_RED); } display.println(""`abcdefghijklmno""); display.println(""pqrstuvwxyz{|}~ ""); } void showPartialUpdate(GxEPD2_GFX& display) { // some useful background helloWorld(display); // use asymmetric values for test uint16_t box_x = 10; uint16_t box_y = 15; uint16_t box_w = 70; uint16_t box_h = 20; uint16_t cursor_y = box_y + box_h - 6; float value = 13.95; uint16_t incr = display.epd2.hasFastPartialUpdate ? 1 : 3; display.setFont(&FreeMonoBold9pt7b); display.setTextColor(GxEPD_BLACK); // show where the update box is for (uint16_t r = 0; r < 4; r++) { display.setRotation(r); display.setPartialWindow(box_x, box_y, box_w, box_h); display.firstPage(); do { display.fillRect(box_x, box_y, box_w, box_h, GxEPD_BLACK); //display.fillScreen(GxEPD_BLACK); } while (display.nextPage()); delay(2000); display.firstPage(); do { display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); } while (display.nextPage()); delay(1000); } //return; // show updates in the update box for (uint16_t r = 0; r < 4; r++) { display.setRotation(r); display.setPartialWindow(box_x, box_y, box_w, box_h); for (uint16_t i = 1; i <= 10; i += incr) { display.firstPage(); do { display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); display.setCursor(box_x, cursor_y); display.print(value * i, 2); } while (display.nextPage()); delay(500); } delay(1000); display.firstPage(); do { display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE); } while (display.nextPage()); delay(1000); } } #ifdef _GxBitmaps200x200_H_ void drawBitmaps200x200(GxEPD2_GFX& display); void drawBitmaps200x200(GxEPD2_GFX& display) { #if defined(__AVR) const unsigned char* bitmaps[] = { logo200x200, first200x200 //, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200 }; #elif defined(_BOARD_GENERIC_STM32F103C_H_) const unsigned char* bitmaps[] = { logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200 //, sixth200x200, senventh200x200, eighth200x200 }; #else const unsigned char* bitmaps[] = { logo200x200, first200x200, second200x200, third200x200, fourth200x200, fifth200x200, sixth200x200, senventh200x200, eighth200x200 }; #endif if ((display.epd2.panel == GxEPD2::GDEP015OC1) || (display.epd2.panel == GxEPD2::GDEH0154D67)) { bool m = display.mirror(true); for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++) { display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK); } while (display.nextPage()); delay(2000); } display.mirror(m); } //else { bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1); display.clearScreen(); // use default for white int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2; int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2; for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++) { display.drawImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true); delay(2000); } } bool mirror_y = (display.epd2.panel != GxEPD2::GDE0213B1); for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++) { int16_t x = -60; int16_t y = -60; for (uint16_t j = 0; j < 10; j++) { display.writeScreenBuffer(); // use default for white display.writeImage(bitmaps[i], x, y, 200, 200, false, mirror_y, true); display.refresh(true); if (display.epd2.hasFastPartialUpdate) { // for differential update: set previous buffer equal to current buffer in controller display.epd2.writeScreenBufferAgain(); // use default for white display.epd2.writeImageAgain(bitmaps[i], x, y, 200, 200, false, mirror_y, true); } delay(2000); x += 40; y += 40; if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break; } if (!display.epd2.hasFastPartialUpdate) break; // comment out for full show break; // comment out for full show } display.writeScreenBuffer(); // use default for white display.writeImage(bitmaps[0], int16_t(0), 0, 200, 200, false, mirror_y, true); display.writeImage(bitmaps[0], int16_t(int16_t(display.epd2.WIDTH) - 200), int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, mirror_y, true); display.refresh(true); delay(2000); } #endif #ifdef _GxBitmaps128x250_H_ void drawBitmaps128x250(GxEPD2_GFX& display); void drawBitmaps128x250(GxEPD2_GFX& display) { #if !defined(__AVR) const unsigned char* bitmaps[] = { Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250 }; #else const unsigned char* bitmaps[] = { Bitmap128x250_1, logo128x250, first128x250, second128x250, third128x250 }; #endif if (display.epd2.panel == GxEPD2::GDE0213B1) { bool m = display.mirror(true); for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++) { display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK); } while (display.nextPage()); delay(2000); } display.mirror(m); } } #endif #ifdef _GxBitmaps128x296_H_ void drawBitmaps128x296(GxEPD2_GFX& display); void drawBitmaps128x296(GxEPD2_GFX& display) { #if !defined(__AVR) const unsigned char* bitmaps[] = { Bitmap128x296_1, logo128x296, first128x296, second128x296, third128x296 }; #else const unsigned char* bitmaps[] = { Bitmap128x296_1, logo128x296 //, first128x296, second128x296, third128x296 }; #endif if (display.epd2.panel == GxEPD2::GDEH029A1) { bool m = display.mirror(true); for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++) { display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK); } while (display.nextPage()); delay(2000); } display.mirror(m); } } #endif #ifdef _GxBitmaps176x264_H_ void drawBitmaps176x264(GxEPD2_GFX& display); void drawBitmaps176x264(GxEPD2_GFX& display) { const unsigned char* bitmaps[] = { Bitmap176x264_1, Bitmap176x264_2 }; if (display.epd2.panel == GxEPD2::GDEW027W3) { for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++) { display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK); } while (display.nextPage()); delay(2000); } } } #endif #ifdef _GxBitmaps400x300_H_ void drawBitmaps400x300(GxEPD2_GFX& display); void drawBitmaps400x300(GxEPD2_GFX& display) { #if !defined(__AVR) const unsigned char* bitmaps[] = { Bitmap400x300_1, Bitmap400x300_2 }; #else const unsigned char* bitmaps[] = {}; // not enough code space #endif if (display.epd2.panel == GxEPD2::GDEW042T2) { for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++) { display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK); } while (display.nextPage()); delay(2000); } } } #endif #ifdef _GxBitmaps640x384_H_ void drawBitmaps640x384(GxEPD2_GFX& display); void drawBitmaps640x384(GxEPD2_GFX& display) { #if !defined(__AVR) const unsigned char* bitmaps[] = { Bitmap640x384_1, Bitmap640x384_2 }; #else const unsigned char* bitmaps[] = {}; // not enough code space #endif if (display.epd2.panel == GxEPD2::GDEW075T8) { for (uint16_t i = 0; i < sizeof(bitmaps) / sizeof(char*); i++) { display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.drawInvertedBitmap(0, 0, bitmaps[i], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK); } while (display.nextPage()); delay(2000); } } } #endif struct bitmap_pair { const unsigned char* black; const unsigned char* red; }; #ifdef _GxBitmaps3c200x200_H_ void drawBitmaps3c200x200(GxEPD2_GFX& display); void drawBitmaps3c200x200(GxEPD2_GFX& display) { bitmap_pair bitmap_pairs[] = { //{Bitmap3c200x200_black, Bitmap3c200x200_red}, {WS_Bitmap3c200x200_black, WS_Bitmap3c200x200_red} }; if (display.epd2.panel == GxEPD2::GDEW0154Z04) { display.firstPage(); do { display.fillScreen(GxEPD_WHITE); // Bitmap3c200x200_black has 2 bits per pixel // taken from Adafruit_GFX.cpp, modified int16_t byteWidth = (display.epd2.WIDTH + 7) / 8; // Bitmap scanline pad = whole byte uint8_t byte = 0; for (int16_t j = 0; j < display.epd2.HEIGHT; j++) { for (int16_t i = 0; i < display.epd2.WIDTH; i++) { if (i & 3) byte <<= 2; else { #if defined(__AVR) || defined(ESP8266) || defined(ESP32) byte = pgm_read_byte(&Bitmap3c200x200_black[j * byteWidth * 2 + i / 4]); #else byte = Bitmap3c200x200_black[j * byteWidth * 2 + i / 4]; #endif } if (!(byte & 0x80)) { display.drawPixel(i, j, GxEPD_BLACK); } } } display.drawInvertedBitmap(0, 0, Bitmap3c200x200_red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED); } while (display.nextPage()); delay(2000); for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++) { display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK); display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED); } while (display.nextPage()); delay(2000); } } if (display.epd2.hasColor) { display.clearScreen(); // use default for white int16_t x = (int16_t(display.epd2.WIDTH) - 200) / 2; int16_t y = (int16_t(display.epd2.HEIGHT) - 200) / 2; for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++) { display.drawImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true); delay(2000); } for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++) { int16_t x = -60; int16_t y = -60; for (uint16_t j = 0; j < 10; j++) { display.writeScreenBuffer(); // use default for white display.writeImage(bitmap_pairs[i].black, bitmap_pairs[i].red, x, y, 200, 200, false, false, true); display.refresh(); delay(2000); x += 40; y += 40; if ((x >= int16_t(display.epd2.WIDTH)) || (y >= int16_t(display.epd2.HEIGHT))) break; } } display.writeScreenBuffer(); // use default for white display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, 0, 0, 200, 200, false, false, true); display.writeImage(bitmap_pairs[0].black, bitmap_pairs[0].red, int16_t(display.epd2.WIDTH) - 200, int16_t(display.epd2.HEIGHT) - 200, 200, 200, false, false, true); display.refresh(); delay(2000); } } #endif #ifdef _GxBitmaps3c104x212_H_ void drawBitmaps3c104x212(GxEPD2_GFX& display); void drawBitmaps3c104x212(GxEPD2_GFX& display) { #if !defined(__AVR) bitmap_pair bitmap_pairs[] = { {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red}, {Bitmap3c104x212_2_black, Bitmap3c104x212_2_red}, {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red} }; #else bitmap_pair bitmap_pairs[] = { {Bitmap3c104x212_1_black, Bitmap3c104x212_1_red}, //{Bitmap3c104x212_2_black, Bitmap3c104x212_2_red}, {WS_Bitmap3c104x212_black, WS_Bitmap3c104x212_red} }; #endif if (display.epd2.panel == GxEPD2::GDEW0213Z16) { for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++) { display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK); if (bitmap_pairs[i].red == WS_Bitmap3c104x212_red) { display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED); } else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED); } while (display.nextPage()); delay(2000); } } } #endif #ifdef _GxBitmaps3c128x296_H_ void drawBitmaps3c128x296(GxEPD2_GFX& display); void drawBitmaps3c128x296(GxEPD2_GFX& display) { #if !defined(__AVR) bitmap_pair bitmap_pairs[] = { {Bitmap3c128x296_1_black, Bitmap3c128x296_1_red}, {Bitmap3c128x296_2_black, Bitmap3c128x296_2_red}, {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red} }; #else bitmap_pair bitmap_pairs[] = { //{Bitmap3c128x296_1_black, Bitmap3c128x296_1_red}, //{Bitmap3c128x296_2_black, Bitmap3c128x296_2_red}, {WS_Bitmap3c128x296_black, WS_Bitmap3c128x296_red} }; #endif if (display.epd2.panel == GxEPD2::GDEW029Z10) { for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++) { display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK); if (bitmap_pairs[i].red == WS_Bitmap3c128x296_red) { display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED); } else display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED); } while (display.nextPage()); delay(2000); } } } #endif #ifdef _GxBitmaps3c176x264_H_ void drawBitmaps3c176x264(GxEPD2_GFX& display); void drawBitmaps3c176x264(GxEPD2_GFX& display) { bitmap_pair bitmap_pairs[] = { {Bitmap3c176x264_black, Bitmap3c176x264_red} }; if (display.epd2.panel == GxEPD2::GDEW027C44) { for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++) { display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.drawBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK); display.drawBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED); } while (display.nextPage()); delay(2000); } } } #endif #ifdef _GxBitmaps3c400x300_H_ void drawBitmaps3c400x300(GxEPD2_GFX& display); void drawBitmaps3c400x300(GxEPD2_GFX& display) { #if !defined(__AVR) bitmap_pair bitmap_pairs[] = { {Bitmap3c400x300_1_black, Bitmap3c400x300_1_red}, {Bitmap3c400x300_2_black, Bitmap3c400x300_2_red}, {WS_Bitmap3c400x300_black, WS_Bitmap3c400x300_red} }; #else bitmap_pair bitmap_pairs[] = {}; // not enough code space #endif if (display.epd2.panel == GxEPD2::GDEW042Z15) { for (uint16_t i = 0; i < sizeof(bitmap_pairs) / sizeof(bitmap_pair); i++) { display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.drawInvertedBitmap(0, 0, bitmap_pairs[i].black, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK); display.drawInvertedBitmap(0, 0, bitmap_pairs[i].red, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_RED); } while (display.nextPage()); delay(2000); } } } #endif void drawBitmaps(GxEPD2_GFX& display) { display.setFullWindow(); display.setRotation(0); #ifdef _GxBitmaps128x250_H_ drawBitmaps128x250(display); #endif #ifdef _GxBitmaps128x296_H_ drawBitmaps128x296(display); #endif #ifdef _GxBitmaps176x264_H_ drawBitmaps176x264(display); #endif #ifdef _GxBitmaps400x300_H_ drawBitmaps400x300(display); #endif #ifdef _GxBitmaps640x384_H_ drawBitmaps640x384(display); #endif // 3-color #ifdef _GxBitmaps3c104x212_H_ drawBitmaps3c104x212(display); #endif #ifdef _GxBitmaps3c128x296_H_ drawBitmaps3c128x296(display); #endif #ifdef _GxBitmaps3c176x264_H_ drawBitmaps3c176x264(display); #endif #ifdef _GxBitmaps3c400x300_H_ drawBitmaps3c400x300(display); #endif // show these after the specific bitmaps #ifdef _GxBitmaps200x200_H_ drawBitmaps200x200(display); #endif // 3-color #ifdef _GxBitmaps3c200x200_H_ drawBitmaps3c200x200(display); #endif } ",16288,True,2589.144110050437,median "#include ""HaskinoRuntime.h"" void haskinoMain(); #define HASKINOMAIN_STACK_SIZE 920 byte haskinoMainTcb[sizeof(TCB) + HASKINOMAIN_STACK_SIZE]; // ******** Start of Instrumentation #define TEST_COUNT 1000 #define TEST_CMD 0x20 static uint8_t cmdChar; static uint32_t start; static uint32_t end; static uint32_t cmdCount = 0; static uint32_t charCount; void sendStringf(const char *fmt, ...); // ******** End of Instrumentation void setup() { haskinoMemInit(); createTask(255, haskinoMainTcb, HASKINOMAIN_STACK_SIZE, haskinoMain); scheduleTask(255, 0); startScheduler(); } void loop() { } uint8_t ref0; void haskinoMain() { int32_t bind0; ref0 = 0; serialBegin(0,115200); bind0 = 0; int32_t bind3; uint8_t * bind4 = NULL; uint8_t * bind5 = NULL; while (1) { ref0 = 0; listAssign(&bind4, (uint8_t * ) (const byte[]) {255, 0}); bind3 = 0; int32_t bind6; uint8_t bind8; // ******** Start of Instrumentation charCount = 0; // ******** End of Instrumentation while (1) { bind6 = 0; uint32_t bind9; while (1) { bind9 = serialAvailable(0); if ((0 < bind9)) { int32_t bind10; bind10 = serialRead(0); bind8 = ((uint8_t) ((int32_t) bind10)); break; } else { bind6 = 0; } } if ((bind8 == 125)) { int32_t bind11; uint8_t bind13; uint8_t bind16; bind11 = 0; uint32_t bind14; while (1) { bind14 = serialAvailable(0); if ((0 < bind14)) { int32_t bind15; bind15 = serialRead(0); bind13 = ((uint8_t) ((int32_t) bind15)); break; } else { bind11 = 0; } } bind16 = ref0; ref0 = ((bind16 + bind13) ^ 32); } else { if ((bind8 == 126)) { uint8_t bind17; uint8_t * bind18 = NULL; bind17 = ref0; if ((((uint8_t) (bind17 - list8Elem(bind4,(list8Len(bind4) - 1)))) == ((uint8_t) list8Elem(bind4,(list8Len(bind4) - 1))))) { listAssign(&bind18, list8Slice(bind4,0,(list8Len(bind4) - 1))); } else { listAssign(&bind18, (uint8_t * ) (const byte[]) {255, 0}); } listAssign(&bind5, bind18); listRelease(&bind18); break; } else { uint8_t bind19; // ******** Start of Instrumentation if (charCount == 0 && bind8 == TEST_CMD && cmdCount == 0) { cmdChar = bind8; start = millis(); } if (charCount == 0 && bind8 == TEST_CMD) { cmdCount++; } charCount++; // ******** End of Instrumentation bind19 = ref0; ref0 = (bind19 + bind8); bind3 = 0; listAssign(&bind4, list8Apnd(bind4,list8Cons(bind8,(uint8_t * ) (const byte[]) {255, 0}))); } } } if ((list8Len(bind5) == 0)) { } else { if ((((uint8_t) (list8Elem(bind5,0) & 240)) == 16)) { if ((((uint8_t) list8Elem(bind5,0)) == 16)) { soft_restart(); } else { if ((((uint8_t) list8Elem(bind5,0)) == 17)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 1))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 3))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 4))) == 0))))) { pinMode(list8Elem(bind5,(1 + 2)),(((uint8_t) list8Elem(bind5,(1 + 5))) == 0) ? INPUT : (((uint8_t) list8Elem(bind5,(1 + 5))) == 1) ? OUTPUT : (((uint8_t) list8Elem(bind5,(1 + 5))) == 2) ? INPUT_PULLUP : INPUT); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 18)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 4) && (((uint8_t) list8Elem(bind5,(1 + 2))) == 0))) { int32_t bind27; uint8_t * bind28 = NULL; delayMilliseconds(((((((uint32_t) ((int32_t) list8Elem(bind5,(1 + 6)))) << 24) | (((uint32_t) ((int32_t) list8Elem(bind5,(1 + 5)))) << 16)) | (((uint32_t) ((int32_t) list8Elem(bind5,(1 + 4)))) << 8)) | ((uint32_t) ((int32_t) list8Elem(bind5,(1 + 3)))))); listAssign(&bind28, list8Cons(0,list8Cons(24,(uint8_t * ) (const byte[]) {255, 0}))); bind27 = 0; while (1) { if (((((uint8_t) list8Elem(bind28,1)) == 126) || (((uint8_t) list8Elem(bind28,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind28,1) ^ 32)); } else { serialWrite(0,list8Elem(bind28,1)); } if ((list8Len(bind28) == 2)) { if (((((uint8_t) (list8Elem(bind28,0) + list8Elem(bind28,1))) == 126) || (((uint8_t) (list8Elem(bind28,0) + list8Elem(bind28,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind28,0) + list8Elem(bind28,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind28,0) + list8Elem(bind28,1))); } break; } else { bind27 = 0; listAssign(&bind28, list8Cons((list8Elem(bind28,0) + list8Elem(bind28,1)),list8Slice(bind28,2,0))); } } serialWrite(0,126); listRelease(&bind28); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 19)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 4) && (((uint8_t) list8Elem(bind5,(1 + 2))) == 0))) { int32_t bind34; uint8_t * bind35 = NULL; delayMicroseconds(((((((uint32_t) ((int32_t) list8Elem(bind5,(1 + 6)))) << 24) | (((uint32_t) ((int32_t) list8Elem(bind5,(1 + 5)))) << 16)) | (((uint32_t) ((int32_t) list8Elem(bind5,(1 + 4)))) << 8)) | ((uint32_t) ((int32_t) list8Elem(bind5,(1 + 3)))))); listAssign(&bind35, list8Cons(0,list8Cons(24,(uint8_t * ) (const byte[]) {255, 0}))); bind34 = 0; while (1) { if (((((uint8_t) list8Elem(bind35,1)) == 126) || (((uint8_t) list8Elem(bind35,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind35,1) ^ 32)); } else { serialWrite(0,list8Elem(bind35,1)); } if ((list8Len(bind35) == 2)) { if (((((uint8_t) (list8Elem(bind35,0) + list8Elem(bind35,1))) == 126) || (((uint8_t) (list8Elem(bind35,0) + list8Elem(bind35,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind35,0) + list8Elem(bind35,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind35,0) + list8Elem(bind35,1))); } break; } else { bind34 = 0; listAssign(&bind35, list8Cons((list8Elem(bind35,0) + list8Elem(bind35,1)),list8Slice(bind35,2,0))); } } serialWrite(0,126); listRelease(&bind35); } else { } } else { } } } } } else { if ((((uint8_t) (list8Elem(bind5,0) & 240)) == 32)) { if ((((uint8_t) list8Elem(bind5,0)) == 32)) { uint16_t bind41; int32_t bind42; uint8_t * bind43 = NULL; bind41 = queryFirmware(); listAssign(&bind43, list8Cons(0,list8Cons(40,list8Cons(((uint8_t) ((int32_t) (bind41 & 255))),list8Cons(((uint8_t) ((int32_t) (bind41 >> 8))),(uint8_t * ) (const byte[]) {255, 0}))))); bind42 = 0; while (1) { if (((((uint8_t) list8Elem(bind43,1)) == 126) || (((uint8_t) list8Elem(bind43,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind43,1) ^ 32)); } else { serialWrite(0,list8Elem(bind43,1)); } if ((list8Len(bind43) == 2)) { if (((((uint8_t) (list8Elem(bind43,0) + list8Elem(bind43,1))) == 126) || (((uint8_t) (list8Elem(bind43,0) + list8Elem(bind43,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind43,0) + list8Elem(bind43,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind43,0) + list8Elem(bind43,1))); } break; } else { bind42 = 0; listAssign(&bind43, list8Cons((list8Elem(bind43,0) + list8Elem(bind43,1)),list8Slice(bind43,2,0))); } } serialWrite(0,126); listRelease(&bind43); } else { if ((((uint8_t) list8Elem(bind5,0)) == 33)) { uint8_t bind48; int32_t bind49; uint8_t * bind50 = NULL; bind48 = queryProcessor(); listAssign(&bind50, list8Cons(0,list8Cons(41,list8Cons(bind48,(uint8_t * ) (const byte[]) {255, 0})))); bind49 = 0; while (1) { if (((((uint8_t) list8Elem(bind50,1)) == 126) || (((uint8_t) list8Elem(bind50,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind50,1) ^ 32)); } else { serialWrite(0,list8Elem(bind50,1)); } if ((list8Len(bind50) == 2)) { if (((((uint8_t) (list8Elem(bind50,0) + list8Elem(bind50,1))) == 126) || (((uint8_t) (list8Elem(bind50,0) + list8Elem(bind50,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind50,0) + list8Elem(bind50,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind50,0) + list8Elem(bind50,1))); } break; } else { bind49 = 0; listAssign(&bind50, list8Cons((list8Elem(bind50,0) + list8Elem(bind50,1)),list8Slice(bind50,2,0))); } } serialWrite(0,126); listRelease(&bind50); } else { if ((((uint8_t) list8Elem(bind5,0)) == 34)) { uint32_t bind55; int32_t bind56; uint8_t * bind57 = NULL; bind55 = micros(); listAssign(&bind57, list8Cons(0,list8Cons(42,list8Cons(4,list8Cons(0,list8Cons(((uint8_t) ((int32_t) (bind55 & 255))),list8Cons(((uint8_t) ((int32_t) (bind55 >> 8))),list8Cons(((uint8_t) ((int32_t) (bind55 >> 16))),list8Cons(((uint8_t) ((int32_t) (bind55 >> 24))),(uint8_t * ) (const byte[]) {255, 0}))))))))); bind56 = 0; while (1) { if (((((uint8_t) list8Elem(bind57,1)) == 126) || (((uint8_t) list8Elem(bind57,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind57,1) ^ 32)); } else { serialWrite(0,list8Elem(bind57,1)); } if ((list8Len(bind57) == 2)) { if (((((uint8_t) (list8Elem(bind57,0) + list8Elem(bind57,1))) == 126) || (((uint8_t) (list8Elem(bind57,0) + list8Elem(bind57,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind57,0) + list8Elem(bind57,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind57,0) + list8Elem(bind57,1))); } break; } else { bind56 = 0; listAssign(&bind57, list8Cons((list8Elem(bind57,0) + list8Elem(bind57,1)),list8Slice(bind57,2,0))); } } serialWrite(0,126); listRelease(&bind57); } else { if ((((uint8_t) list8Elem(bind5,0)) == 35)) { uint32_t bind62; int32_t bind63; uint8_t * bind64 = NULL; bind62 = millis(); listAssign(&bind64, list8Cons(0,list8Cons(43,list8Cons(4,list8Cons(0,list8Cons(((uint8_t) ((int32_t) (bind62 & 255))),list8Cons(((uint8_t) ((int32_t) (bind62 >> 8))),list8Cons(((uint8_t) ((int32_t) (bind62 >> 16))),list8Cons(((uint8_t) ((int32_t) (bind62 >> 24))),(uint8_t * ) (const byte[]) {255, 0}))))))))); bind63 = 0; while (1) { if (((((uint8_t) list8Elem(bind64,1)) == 126) || (((uint8_t) list8Elem(bind64,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind64,1) ^ 32)); } else { serialWrite(0,list8Elem(bind64,1)); } if ((list8Len(bind64) == 2)) { if (((((uint8_t) (list8Elem(bind64,0) + list8Elem(bind64,1))) == 126) || (((uint8_t) (list8Elem(bind64,0) + list8Elem(bind64,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind64,0) + list8Elem(bind64,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind64,0) + list8Elem(bind64,1))); } break; } else { bind63 = 0; listAssign(&bind64, list8Cons((list8Elem(bind64,0) + list8Elem(bind64,1)),list8Slice(bind64,2,0))); } } serialWrite(0,126); listRelease(&bind64); } else { if ((((uint8_t) list8Elem(bind5,0)) == 0)) { int32_t bind69; uint8_t * bind70 = NULL; listAssign(&bind70, list8Cons(0,list8Cons(44,list8Slice(bind5,1,0)))); bind69 = 0; while (1) { if (((((uint8_t) list8Elem(bind70,1)) == 126) || (((uint8_t) list8Elem(bind70,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind70,1) ^ 32)); } else { serialWrite(0,list8Elem(bind70,1)); } if ((list8Len(bind70) == 2)) { if (((((uint8_t) (list8Elem(bind70,0) + list8Elem(bind70,1))) == 126) || (((uint8_t) (list8Elem(bind70,0) + list8Elem(bind70,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind70,0) + list8Elem(bind70,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind70,0) + list8Elem(bind70,1))); } break; } else { bind69 = 0; listAssign(&bind70, list8Cons((list8Elem(bind70,0) + list8Elem(bind70,1)),list8Slice(bind70,2,0))); } } serialWrite(0,126); listRelease(&bind70); } else { } } } } } } else { if ((((uint8_t) (list8Elem(bind5,0) & 240)) == 48)) { if ((((uint8_t) list8Elem(bind5,0)) == 48)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 2))) == 0))) { bool bind77; int32_t bind78; uint8_t * bind79 = NULL; bind77 = digitalRead(list8Elem(bind5,(1 + 3))); listAssign(&bind79, list8Cons(0,list8Cons(56,list8Cons(1,list8Cons(0,list8Cons(bind77 ? 1 : 0,(uint8_t * ) (const byte[]) {255, 0})))))); bind78 = 0; while (1) { if (((((uint8_t) list8Elem(bind79,1)) == 126) || (((uint8_t) list8Elem(bind79,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind79,1) ^ 32)); } else { serialWrite(0,list8Elem(bind79,1)); } if ((list8Len(bind79) == 2)) { if (((((uint8_t) (list8Elem(bind79,0) + list8Elem(bind79,1))) == 126) || (((uint8_t) (list8Elem(bind79,0) + list8Elem(bind79,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind79,0) + list8Elem(bind79,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind79,0) + list8Elem(bind79,1))); } break; } else { bind78 = 0; listAssign(&bind79, list8Cons((list8Elem(bind79,0) + list8Elem(bind79,1)),list8Slice(bind79,2,0))); } } serialWrite(0,126); listRelease(&bind79); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 49)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 1))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 3))) == 1) && (((uint8_t) list8Elem(bind5,(1 + 4))) == 0))))) { digitalWrite(list8Elem(bind5,(1 + 2)),(((uint8_t) list8Elem(bind5,(1 + 5))) == 0) ? 0 : 1); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 50)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 2))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 4))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 5))) == 0))))) { uint8_t bind87; int32_t bind88; uint8_t * bind89 = NULL; bind87 = digitalPortRead(list8Elem(bind5,(1 + 3)),list8Elem(bind5,(1 + 6))); listAssign(&bind89, list8Cons(0,list8Cons(57,list8Cons(2,list8Cons(0,list8Cons(bind87,(uint8_t * ) (const byte[]) {255, 0})))))); bind88 = 0; while (1) { if (((((uint8_t) list8Elem(bind89,1)) == 126) || (((uint8_t) list8Elem(bind89,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind89,1) ^ 32)); } else { serialWrite(0,list8Elem(bind89,1)); } if ((list8Len(bind89) == 2)) { if (((((uint8_t) (list8Elem(bind89,0) + list8Elem(bind89,1))) == 126) || (((uint8_t) (list8Elem(bind89,0) + list8Elem(bind89,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind89,0) + list8Elem(bind89,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind89,0) + list8Elem(bind89,1))); } break; } else { bind88 = 0; listAssign(&bind89, list8Cons((list8Elem(bind89,0) + list8Elem(bind89,1)),list8Slice(bind89,2,0))); } } serialWrite(0,126); listRelease(&bind89); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 51)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 1))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 3))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 4))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 6))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 7))) == 0))))))) { digitalPortWrite(list8Elem(bind5,(1 + 2)),list8Elem(bind5,(1 + 5)),list8Elem(bind5,(1 + 8))); } else { } } else { } } } } } else { if ((((uint8_t) (list8Elem(bind5,0) & 240)) == 64)) { if ((((uint8_t) list8Elem(bind5,0)) == 64)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 2))) == 0))) { uint16_t bind98; int32_t bind99; uint8_t * bind100 = NULL; bind98 = analogRead(list8Elem(bind5,(1 + 3))); listAssign(&bind100, list8Cons(0,list8Cons(72,list8Cons(3,list8Cons(0,list8Cons(((uint8_t) ((int32_t) (bind98 & 255))),list8Cons(((uint8_t) ((int32_t) (bind98 >> 8))),(uint8_t * ) (const byte[]) {255, 0}))))))); bind99 = 0; while (1) { if (((((uint8_t) list8Elem(bind100,1)) == 126) || (((uint8_t) list8Elem(bind100,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind100,1) ^ 32)); } else { serialWrite(0,list8Elem(bind100,1)); } if ((list8Len(bind100) == 2)) { if (((((uint8_t) (list8Elem(bind100,0) + list8Elem(bind100,1))) == 126) || (((uint8_t) (list8Elem(bind100,0) + list8Elem(bind100,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind100,0) + list8Elem(bind100,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind100,0) + list8Elem(bind100,1))); } break; } else { bind99 = 0; listAssign(&bind100, list8Cons((list8Elem(bind100,0) + list8Elem(bind100,1)),list8Slice(bind100,2,0))); } } serialWrite(0,126); listRelease(&bind100); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 65)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 1))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 3))) == 3) && (((uint8_t) list8Elem(bind5,(1 + 4))) == 0))))) { analogWrite(list8Elem(bind5,(1 + 2)),((((uint16_t) ((int32_t) list8Elem(bind5,(1 + 6)))) << 8) | ((uint16_t) ((int32_t) list8Elem(bind5,(1 + 5)))))); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 66)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 1))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 3))) == 3) && ((((uint8_t) list8Elem(bind5,(1 + 4))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 7))) == 4) && (((uint8_t) list8Elem(bind5,(1 + 8))) == 0))))))) { if ((((((((uint32_t) ((int32_t) list8Elem(bind5,(1 + 11)))) << 24) | (((uint32_t) ((int32_t) list8Elem(bind5,(1 + 10)))) << 16)) | (((uint32_t) ((int32_t) list8Elem(bind5,(1 + 9)))) << 8)) | ((uint32_t) ((int32_t) list8Elem(bind5,(1 + 8))))) == 0)) { tone(list8Elem(bind5,(1 + 2)),((((uint16_t) ((int32_t) list8Elem(bind5,(1 + 6)))) << 8) | ((uint16_t) ((int32_t) list8Elem(bind5,(1 + 5))))),0); } else { tone(list8Elem(bind5,(1 + 2)),((((uint16_t) ((int32_t) list8Elem(bind5,(1 + 6)))) << 8) | ((uint16_t) ((int32_t) list8Elem(bind5,(1 + 5))))),((((((uint32_t) ((int32_t) list8Elem(bind5,(1 + 11)))) << 24) | (((uint32_t) ((int32_t) list8Elem(bind5,(1 + 10)))) << 16)) | (((uint32_t) ((int32_t) list8Elem(bind5,(1 + 9)))) << 8)) | ((uint32_t) ((int32_t) list8Elem(bind5,(1 + 8)))))); } } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 67)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 1))) == 0))) { noTone(list8Elem(bind5,(1 + 2))); } else { } } else { } } } } } else { if ((((uint8_t) (list8Elem(bind5,0) & 240)) == 80)) { if ((((uint8_t) list8Elem(bind5,0)) == 80)) { i2cConfig(); } else { if ((((uint8_t) list8Elem(bind5,0)) == 81)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 2))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 4))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 5))) == 0))))) { uint8_t * bind115 = NULL; int32_t bind116; uint8_t * bind117 = NULL; listAssign(&bind115, i2cRead(list8Elem(bind5,(1 + 3)),list8Elem(bind5,(1 + 6)))); listAssign(&bind117, list8Cons(0,list8Cons(88,list8Cons(8,list8Cons(0,list8Cons(((uint8_t) list8Len(bind115)),bind115)))))); bind116 = 0; while (1) { if (((((uint8_t) list8Elem(bind117,1)) == 126) || (((uint8_t) list8Elem(bind117,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind117,1) ^ 32)); } else { serialWrite(0,list8Elem(bind117,1)); } if ((list8Len(bind117) == 2)) { if (((((uint8_t) (list8Elem(bind117,0) + list8Elem(bind117,1))) == 126) || (((uint8_t) (list8Elem(bind117,0) + list8Elem(bind117,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind117,0) + list8Elem(bind117,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind117,0) + list8Elem(bind117,1))); } break; } else { bind116 = 0; listAssign(&bind117, list8Cons((list8Elem(bind117,0) + list8Elem(bind117,1)),list8Slice(bind117,2,0))); } } serialWrite(0,126); listRelease(&bind115); listRelease(&bind117); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 82)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 1))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 3))) == 8) && ((((uint8_t) list8Elem(bind5,(1 + 4))) == 0) && ((list8Len(bind5) - 1) == (((int32_t) list8Elem(bind5,(1 + 5))) + 6))))))) { i2cWrite(list8Elem(bind5,(1 + 2)),list8Slice(list8Slice(bind5,1,0),6,0)); } else { } } else { } } } } else { if ((((uint8_t) (list8Elem(bind5,0) & 240)) == 224)) { if ((((uint8_t) list8Elem(bind5,0)) == 224)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 1))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 3))) == 4) && (((uint8_t) list8Elem(bind5,(1 + 4))) == 0))))) { serialBegin(list8Elem(bind5,(1 + 2)),((((((uint32_t) ((int32_t) list8Elem(bind5,(1 + 8)))) << 24) | (((uint32_t) ((int32_t) list8Elem(bind5,(1 + 7)))) << 16)) | (((uint32_t) ((int32_t) list8Elem(bind5,(1 + 6)))) << 8)) | ((uint32_t) ((int32_t) list8Elem(bind5,(1 + 5)))))); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 225)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 1))) == 0))) { serialEnd(list8Elem(bind5,(1 + 2))); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 227)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 2))) == 0))) { int32_t bind130; int32_t bind131; uint8_t * bind132 = NULL; bind130 = serialRead(list8Elem(bind5,(1 + 3))); listAssign(&bind132, list8Cons(0,list8Cons(233,list8Cons(4,list8Cons(0,list8Cons(((uint8_t) ((int32_t) (bind130 & 255))),list8Cons(((uint8_t) ((int32_t) (bind130 >> 8))),list8Cons(((uint8_t) ((int32_t) (bind130 >> 16))),list8Cons(((uint8_t) ((int32_t) (bind130 >> 24))),(uint8_t * ) (const byte[]) {255, 0}))))))))); bind131 = 0; while (1) { if (((((uint8_t) list8Elem(bind132,1)) == 126) || (((uint8_t) list8Elem(bind132,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind132,1) ^ 32)); } else { serialWrite(0,list8Elem(bind132,1)); } if ((list8Len(bind132) == 2)) { if (((((uint8_t) (list8Elem(bind132,0) + list8Elem(bind132,1))) == 126) || (((uint8_t) (list8Elem(bind132,0) + list8Elem(bind132,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind132,0) + list8Elem(bind132,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind132,0) + list8Elem(bind132,1))); } break; } else { bind131 = 0; listAssign(&bind132, list8Cons((list8Elem(bind132,0) + list8Elem(bind132,1)),list8Slice(bind132,2,0))); } } serialWrite(0,126); listRelease(&bind132); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 228)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 2))) == 0))) { uint8_t * bind138 = NULL; int32_t bind139; uint8_t * bind140 = NULL; listAssign(&bind138, serialReadList(list8Elem(bind5,(1 + 3)))); listAssign(&bind140, list8Cons(0,list8Cons(234,list8Cons(8,list8Cons(0,list8Cons(((uint8_t) list8Len(bind138)),bind138)))))); bind139 = 0; while (1) { if (((((uint8_t) list8Elem(bind140,1)) == 126) || (((uint8_t) list8Elem(bind140,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind140,1) ^ 32)); } else { serialWrite(0,list8Elem(bind140,1)); } if ((list8Len(bind140) == 2)) { if (((((uint8_t) (list8Elem(bind140,0) + list8Elem(bind140,1))) == 126) || (((uint8_t) (list8Elem(bind140,0) + list8Elem(bind140,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind140,0) + list8Elem(bind140,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind140,0) + list8Elem(bind140,1))); } break; } else { bind139 = 0; listAssign(&bind140, list8Cons((list8Elem(bind140,0) + list8Elem(bind140,1)),list8Slice(bind140,2,0))); } } serialWrite(0,126); listRelease(&bind138); listRelease(&bind140); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 229)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 1))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 3))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 4))) == 0))))) { serialWrite(list8Elem(bind5,(1 + 2)),list8Elem(bind5,(1 + 5))); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 230)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 1))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 3))) == 8) && ((((uint8_t) list8Elem(bind5,(1 + 4))) == 0) && ((list8Len(bind5) - 1) == (((int32_t) list8Elem(bind5,(1 + 5))) + 6))))))) { serialWriteList(list8Elem(bind5,(1 + 2)),list8Slice(list8Slice(bind5,1,0),6,0)); } else { } } else { } } } } } } } else { if ((((uint8_t) (list8Elem(bind5,0) & 240)) == 96)) { if ((((uint8_t) list8Elem(bind5,0)) == 96)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 3) && ((((uint8_t) list8Elem(bind5,(1 + 2))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 5))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 6))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 8))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 9))) == 0))))))) { uint8_t bind151; int32_t bind152; uint8_t * bind153 = NULL; bind151 = stepper2Pin(((((uint16_t) ((int32_t) list8Elem(bind5,(1 + 4)))) << 8) | ((uint16_t) ((int32_t) list8Elem(bind5,(1 + 3))))),list8Elem(bind5,(1 + 7)),list8Elem(bind5,(1 + 10))); listAssign(&bind153, list8Cons(0,list8Cons(104,list8Cons(2,list8Cons(0,list8Cons(bind151,(uint8_t * ) (const byte[]) {255, 0})))))); bind152 = 0; while (1) { if (((((uint8_t) list8Elem(bind153,1)) == 126) || (((uint8_t) list8Elem(bind153,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind153,1) ^ 32)); } else { serialWrite(0,list8Elem(bind153,1)); } if ((list8Len(bind153) == 2)) { if (((((uint8_t) (list8Elem(bind153,0) + list8Elem(bind153,1))) == 126) || (((uint8_t) (list8Elem(bind153,0) + list8Elem(bind153,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind153,0) + list8Elem(bind153,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind153,0) + list8Elem(bind153,1))); } break; } else { bind152 = 0; listAssign(&bind153, list8Cons((list8Elem(bind153,0) + list8Elem(bind153,1)),list8Slice(bind153,2,0))); } } serialWrite(0,126); listRelease(&bind153); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 97)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 3) && ((((uint8_t) list8Elem(bind5,(1 + 2))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 5))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 6))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 8))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 9))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 11))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 12))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 14))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 15))) == 0))))))))))) { uint8_t bind159; int32_t bind160; uint8_t * bind161 = NULL; bind159 = stepper4Pin(((((((uint16_t) ((int32_t) list8Elem(bind5,(1 + 6)))) << 24) | (((uint16_t) ((int32_t) list8Elem(bind5,(1 + 5)))) << 16)) | (((uint16_t) ((int32_t) list8Elem(bind5,(1 + 4)))) << 8)) | ((uint16_t) ((int32_t) list8Elem(bind5,(1 + 3))))),list8Elem(bind5,(1 + 7)),list8Elem(bind5,(1 + 10)),list8Elem(bind5,(1 + 13)),list8Elem(bind5,(1 + 16))); listAssign(&bind161, list8Cons(0,list8Cons(104,list8Cons(2,list8Cons(0,list8Cons(bind159,(uint8_t * ) (const byte[]) {255, 0})))))); bind160 = 0; while (1) { if (((((uint8_t) list8Elem(bind161,1)) == 126) || (((uint8_t) list8Elem(bind161,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind161,1) ^ 32)); } else { serialWrite(0,list8Elem(bind161,1)); } if ((list8Len(bind161) == 2)) { if (((((uint8_t) (list8Elem(bind161,0) + list8Elem(bind161,1))) == 126) || (((uint8_t) (list8Elem(bind161,0) + list8Elem(bind161,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind161,0) + list8Elem(bind161,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind161,0) + list8Elem(bind161,1))); } break; } else { bind160 = 0; listAssign(&bind161, list8Cons((list8Elem(bind161,0) + list8Elem(bind161,1)),list8Slice(bind161,2,0))); } } serialWrite(0,126); listRelease(&bind161); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 98)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 1))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 3))) == 4) && (((uint8_t) list8Elem(bind5,(1 + 4))) == 0))))) { stepperSetSpeed(list8Elem(bind5,(1 + 2)),((((((int32_t) ((int32_t) list8Elem(bind5,(1 + 8)))) << 24) | (((int32_t) ((int32_t) list8Elem(bind5,(1 + 7)))) << 16)) | (((int32_t) ((int32_t) list8Elem(bind5,(1 + 6)))) << 8)) | ((int32_t) ((int32_t) list8Elem(bind5,(1 + 5)))))); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 99)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 2))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 4))) == 3) && (((uint8_t) list8Elem(bind5,(1 + 5))) == 0))))) { int32_t bind169; uint8_t * bind170 = NULL; stepperSetSpeed(list8Elem(bind5,(1 + 3)),((((int32_t) ((int32_t) list8Elem(bind5,(1 + 7)))) << 8) | ((int32_t) ((int32_t) list8Elem(bind5,(1 + 6)))))); listAssign(&bind170, list8Cons(0,list8Cons(106,(uint8_t * ) (const byte[]) {255, 0}))); bind169 = 0; while (1) { if (((((uint8_t) list8Elem(bind170,1)) == 126) || (((uint8_t) list8Elem(bind170,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind170,1) ^ 32)); } else { serialWrite(0,list8Elem(bind170,1)); } if ((list8Len(bind170) == 2)) { if (((((uint8_t) (list8Elem(bind170,0) + list8Elem(bind170,1))) == 126) || (((uint8_t) (list8Elem(bind170,0) + list8Elem(bind170,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind170,0) + list8Elem(bind170,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind170,0) + list8Elem(bind170,1))); } break; } else { bind169 = 0; listAssign(&bind170, list8Cons((list8Elem(bind170,0) + list8Elem(bind170,1)),list8Slice(bind170,2,0))); } } serialWrite(0,126); listRelease(&bind170); } else { } } else { } } } } } else { if ((((uint8_t) (list8Elem(bind5,0) & 240)) == 128)) { if ((((uint8_t) list8Elem(bind5,0)) == 128)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 2))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 4))) == 3) && ((((uint8_t) list8Elem(bind5,(1 + 5))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 8))) == 3) && (((uint8_t) list8Elem(bind5,(1 + 9))) == 0))))))) { uint8_t bind177; int32_t bind178; uint8_t * bind179 = NULL; bind177 = servoAttachMinMax(list8Elem(bind5,(1 + 3)),((((int16_t) ((int32_t) list8Elem(bind5,(1 + 7)))) << 8) | ((int16_t) ((int32_t) list8Elem(bind5,(1 + 6))))),((((int16_t) ((int32_t) list8Elem(bind5,(1 + 11)))) << 8) | ((int16_t) ((int32_t) list8Elem(bind5,(1 + 10)))))); listAssign(&bind179, list8Cons(0,list8Cons(136,list8Cons(2,list8Cons(0,list8Cons(bind177,(uint8_t * ) (const byte[]) {255, 0})))))); bind178 = 0; while (1) { if (((((uint8_t) list8Elem(bind179,1)) == 126) || (((uint8_t) list8Elem(bind179,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind179,1) ^ 32)); } else { serialWrite(0,list8Elem(bind179,1)); } if ((list8Len(bind179) == 2)) { if (((((uint8_t) (list8Elem(bind179,0) + list8Elem(bind179,1))) == 126) || (((uint8_t) (list8Elem(bind179,0) + list8Elem(bind179,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind179,0) + list8Elem(bind179,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind179,0) + list8Elem(bind179,1))); } break; } else { bind178 = 0; listAssign(&bind179, list8Cons((list8Elem(bind179,0) + list8Elem(bind179,1)),list8Slice(bind179,2,0))); } } serialWrite(0,126); listRelease(&bind179); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 129)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 1))) == 0))) { servoDetach(list8Elem(bind5,(1 + 2))); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 130)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 1))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 3))) == 3) && (((uint8_t) list8Elem(bind5,(1 + 4))) == 0))))) { servoWrite(list8Elem(bind5,(1 + 2)),((((int16_t) ((int32_t) list8Elem(bind5,(1 + 5)))) << 8) | ((int16_t) ((int32_t) list8Elem(bind5,(1 + 6)))))); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 131)) { if (((((uint8_t) list8Elem(bind5,(1 + 0))) == 2) && ((((uint8_t) list8Elem(bind5,(1 + 1))) == 0) && ((((uint8_t) list8Elem(bind5,(1 + 3))) == 3) && (((uint8_t) list8Elem(bind5,(1 + 4))) == 0))))) { servoWrite(list8Elem(bind5,(1 + 2)),((((int16_t) ((int32_t) list8Elem(bind5,(1 + 6)))) << 8) | ((int16_t) ((int32_t) list8Elem(bind5,(1 + 5)))))); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 132)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 2))) == 0))) { uint16_t bind191; int32_t bind192; uint8_t * bind193 = NULL; bind191 = servoRead(list8Elem(bind5,(1 + 3))); listAssign(&bind193, list8Cons(0,list8Cons(137,list8Cons(3,list8Cons(0,list8Cons(((uint8_t) ((int32_t) (bind191 & 255))),list8Cons(((uint8_t) ((int32_t) (bind191 >> 8))),(uint8_t * ) (const byte[]) {255, 0}))))))); bind192 = 0; while (1) { if (((((uint8_t) list8Elem(bind193,1)) == 126) || (((uint8_t) list8Elem(bind193,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind193,1) ^ 32)); } else { serialWrite(0,list8Elem(bind193,1)); } if ((list8Len(bind193) == 2)) { if (((((uint8_t) (list8Elem(bind193,0) + list8Elem(bind193,1))) == 126) || (((uint8_t) (list8Elem(bind193,0) + list8Elem(bind193,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind193,0) + list8Elem(bind193,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind193,0) + list8Elem(bind193,1))); } break; } else { bind192 = 0; listAssign(&bind193, list8Cons((list8Elem(bind193,0) + list8Elem(bind193,1)),list8Slice(bind193,2,0))); } } serialWrite(0,126); listRelease(&bind193); } else { } } else { if ((((uint8_t) list8Elem(bind5,0)) == 133)) { if (((((uint8_t) list8Elem(bind5,(1 + 1))) == 2) && (((uint8_t) list8Elem(bind5,(1 + 2))) == 0))) { uint16_t bind199; int32_t bind200; uint8_t * bind201 = NULL; bind199 = servoReadMicros(list8Elem(bind5,(1 + 3))); listAssign(&bind201, list8Cons(0,list8Cons(137,list8Cons(3,list8Cons(0,list8Cons(((uint8_t) ((int32_t) (bind199 & 255))),list8Cons(((uint8_t) ((int32_t) (bind199 >> 8))),(uint8_t * ) (const byte[]) {255, 0}))))))); bind200 = 0; while (1) { if (((((uint8_t) list8Elem(bind201,1)) == 126) || (((uint8_t) list8Elem(bind201,1)) == 125))) { serialWrite(0,125); serialWrite(0,(list8Elem(bind201,1) ^ 32)); } else { serialWrite(0,list8Elem(bind201,1)); } if ((list8Len(bind201) == 2)) { if (((((uint8_t) (list8Elem(bind201,0) + list8Elem(bind201,1))) == 126) || (((uint8_t) (list8Elem(bind201,0) + list8Elem(bind201,1))) == 125))) { serialWrite(0,125); serialWrite(0,((list8Elem(bind201,0) + list8Elem(bind201,1)) ^ 32)); } else { serialWrite(0,(list8Elem(bind201,0) + list8Elem(bind201,1))); } break; } else { bind200 = 0; listAssign(&bind201, list8Cons((list8Elem(bind201,0) + list8Elem(bind201,1)),list8Slice(bind201,2,0))); } } serialWrite(0,126); listRelease(&bind201); } else { } } else { } } } } } } } else { } } } } } } } } } // ******** Start of Instrumentation if (cmdCount == TEST_COUNT) { end = millis(); sendStringf(""***TestEnd*** %d"", end - start); } // ******** End of Instrumentation } taskComplete(); } ",16130,True,5046.91091505268,median "//////////////////////////////////////////////////////////////////////////////// // // ADOBE SYSTEMS INCORPORATED // Copyright 2003-2007 Adobe Systems Incorporated // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file // in accordance with the terms of the license agreement accompanying it. // //////////////////////////////////////////////////////////////////////////////// package mx.preloaders { import flash.display.DisplayObject; import flash.display.GradientType; import flash.display.Graphics; import flash.display.Loader; import flash.display.LoaderInfo; import flash.display.Sprite; import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.ProgressEvent; import flash.events.TimerEvent; import flash.geom.Matrix; import flash.geom.Rectangle; import flash.net.URLRequest; import flash.system.ApplicationDomain; import flash.system.LoaderContext; import flash.text.TextField; import flash.text.TextFormat; import flash.utils.Timer; import flash.utils.getDefinitionByName; import flash.utils.getTimer; import mx.events.FlexEvent; import mx.events.RSLEvent; import mx.geom.RoundedRectangle; import mx.graphics.RectangularDropShadow; /** * The DownloadProgressBar class displays download progress. * It is used by the Preloader control to provide user feedback * while the application is downloading and loading. * *

The download progress bar displays information about * two different phases of the application: * the download phase and the initialization phase.

* *

In the Application container, use the * the preloader property to specify the name of your subclass.

* *

You can implement a custom download progress bar component * by creating a subclass of the DownloadProgressBar class. * Do not implement a download progress bar as an MXML component * because it loads too slowly.

* * @see mx.core.Application * @see mx.preloaders.IPreloaderDisplay * @see mx.preloaders.Preloader * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public class DownloadProgressBar extends Sprite implements IPreloaderDisplay { include ""../core/Version.as""; //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * Constructor. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function DownloadProgressBar() { super(); } //-------------------------------------------------------------------------- // // Variables // //-------------------------------------------------------------------------- /** * The minimum number of milliseconds * that the display should appear visible. * If the downloading and initialization of the application * takes less time than this value, then Flex pauses for this amount * of time before dispatching the complete event. * * @default 0 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected var MINIMUM_DISPLAY_TIME:uint = 0; /** * The percentage of the progress bar that the downloading phase * fills when the SWF file is fully downloaded. * The rest of the progress bar is filled during the initializing phase. * This should be a value from 0 to 100. * * @default 60 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected var DOWNLOAD_PERCENTAGE:uint = 60; /** * @private */ private var _showProgressBar:Boolean = true; /** * @private * Cached Rectangle returned by the labelRect getter. */ private var _labelRect:Rectangle = labelRect; /** * @private * Cached Rectangle returned by the percentRect getter. */ private var _percentRect:Rectangle = percentRect; /** * @private * Cached RoundedRectangle returned by the borderRect getter. */ private var _borderRect:RoundedRectangle = borderRect; /** * @private * Cached RoundedRectangle returned by the barFrameRect getter. */ private var _barFrameRect:RoundedRectangle = barFrameRect; /** * @private * Cached RoundedRectangle returned by the barRect getter. */ private var _barRect:RoundedRectangle = barRect; /** * @private */ private var _xOffset:Number = 20; /** * @private */ private var _yOffset:Number = 20; /** * @private */ private var _maximum:Number = 0; /** * @private */ private var _value:Number = 0; /** * @private */ private var _barSprite:Sprite; /** * @private */ private var _barFrameSprite:Sprite; /** * @private */ private var _labelObj:TextField; /** * @private */ private var _percentObj:TextField; /** * @private */ private var _startTime:int; /** * @private */ private var _displayTime:int; /** * @private */ private var _startedLoading:Boolean = false; /** * @private */ private var _startedInit:Boolean = false; /** * @private */ private var _showingDisplay:Boolean = false; /** * @private */ private var _displayStartCount:uint = 0; /** * @private */ private var _initProgressCount:uint = 0; /** * The total number of validation events you expect to get * in the initializing phase. This should be an integer * greater or equal to 4 (and note that if it is greater than 4 * you might have an inefficiency in your initialization code) * * @default 6 * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 4 */ protected var initProgressTotal:uint = 6; //-------------------------------------------------------------------------- // // Overridden properties // //-------------------------------------------------------------------------- //---------------------------------- // visible //---------------------------------- /** * @private * Storage for the visible property. */ private var _visible:Boolean = false; /** * Specifies whether the download progress bar is visible. * *

When the Preloader control determines that the progress bar should be displayed, * it sets this value to true. When the Preloader control determines that * the progress bar should be hidden, it sets the value to false.

* *

A subclass of the DownloadProgressBar class should never modify this property. * Instead, you can override the setter method to recognize when * the Preloader control modifies it, and perform any necessary actions.

* * @default false * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ override public function get visible():Boolean { return _visible; } /** * @private */ override public function set visible(value:Boolean):void { if (!_visible && value) show(); else if (_visible && !value ) hide(); _visible = value; } //-------------------------------------------------------------------------- // // Properties: IPreloaderDisplay // //-------------------------------------------------------------------------- //---------------------------------- // backgroundAlpha //---------------------------------- /** * @private * Storage for the backgroundAlpha property. */ private var _backgroundAlpha:Number = 1; /** * Alpha level of the SWF file or image defined by * the backgroundImage property, or the color defined by * the backgroundColor property. * Valid values range from 0 to 1.0. * *

You can specify either a backgroundColor * or a backgroundImage, but not both.

* * @default 1.0 * * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get backgroundAlpha():Number { if (!isNaN(_backgroundAlpha)) return _backgroundAlpha; else return 1; } /** * @private */ public function set backgroundAlpha(value:Number):void { _backgroundAlpha = value; } //---------------------------------- // backgroundColor //---------------------------------- /** * @private * Storage for the backgroundColor property. */ private var _backgroundColor:uint; /** * Background color of a download progress bar. * You can have either a backgroundColor or a * backgroundImage, but not both. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get backgroundColor():uint { return _backgroundColor; } /** * @private */ public function set backgroundColor(value:uint):void { _backgroundColor = value; } //---------------------------------- // backgroundImage //---------------------------------- /** * @private * Storage for the backgroundImage property. */ private var _backgroundImage:Object; /** * The background image of the application, * which is passed in by the preloader. * You can specify either a backgroundColor * or a backgroundImage, but not both. * *

A value of null means ""not set"". * If this style and the backgroundColor style are undefined, * the component has a transparent background.

* *

The preloader does not display embedded images. * You can only use images loaded at runtime.

* * @default null * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get backgroundImage():Object { return _backgroundImage; } /** * @private */ public function set backgroundImage(value:Object):void { _backgroundImage = value; } //---------------------------------- // backgroundSize //---------------------------------- /** * @private * Storage for the backgroundSize property. */ private var _backgroundSize:String = """"; /** * Scales the image specified by backgroundImage * to different percentage sizes. * A value of ""100%"" stretches the image * to fit the entire component. * To specify a percentage value, you must include the percent sign (%). * A value of ""auto"", maintains * the original size of the image. * * @default ""auto"" * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get backgroundSize():String { return _backgroundSize; } /** * @private */ public function set backgroundSize(value:String):void { _backgroundSize = value; } //---------------------------------- // preloader //---------------------------------- /** * @private * Storage for the preloader property. */ private var _preloader:Sprite; /** * The Preloader class passes in a reference to itself to the display class * so that it can listen for events from the preloader. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function set preloader(value:Sprite):void { _preloader = value; value.addEventListener(ProgressEvent.PROGRESS, progressHandler); value.addEventListener(Event.COMPLETE, completeHandler); value.addEventListener(RSLEvent.RSL_PROGRESS, rslProgressHandler); value.addEventListener(RSLEvent.RSL_COMPLETE, rslCompleteHandler); value.addEventListener(RSLEvent.RSL_ERROR, rslErrorHandler); value.addEventListener(FlexEvent.INIT_PROGRESS, initProgressHandler); value.addEventListener(FlexEvent.INIT_COMPLETE, initCompleteHandler); } //---------------------------------- // stageHeight //---------------------------------- /** * @private * Storage for the stageHeight property. */ private var _stageHeight:Number = 375; /** * The height of the stage, * which is passed in by the Preloader class. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get stageHeight():Number { return _stageHeight; } /** * @private */ public function set stageHeight(value:Number):void { _stageHeight = value; } //---------------------------------- // stageWidth //---------------------------------- /** * @private * Storage for the stageHeight property. */ private var _stageWidth:Number = 500; /** * The width of the stage, * which is passed in by the Preloader class. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get stageWidth():Number { return _stageWidth; } /** * @private */ public function set stageWidth(value:Number):void { _stageWidth = value; } //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- //---------------------------------- // barFrameRect //---------------------------------- /** * The dimensions of the progress bar border. * This is a read-only property which you must override * if you need to change it. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get barFrameRect():RoundedRectangle { return new RoundedRectangle(14, 40, 154, 4); } //---------------------------------- // barRect //---------------------------------- /** * The dimensions of the progress bar. * This is a read-only property which you must override * if you need to change it. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get barRect():RoundedRectangle { return new RoundedRectangle(14, 39, 154, 6, 0); } //---------------------------------- // borderRect //---------------------------------- /** * The dimensions of the border of the display. * This is a read-only property which you must override * if you need to change it. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get borderRect():RoundedRectangle { return new RoundedRectangle(0, 0, 182, 60, 4); } //---------------------------------- // downloadingLabel //---------------------------------- /** * @private * Storage for the downloadingLabel property. */ private var _downloadingLabel:String = ""Loading""; /** * The string to display as the label while in the downloading phase. * * @default ""Loading"" * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get downloadingLabel():String { return _downloadingLabel; } /** * @private */ protected function set downloadingLabel(value:String):void { _downloadingLabel = value; } //---------------------------------- // initializingLabel //---------------------------------- /** * @private * Storage for the initializingLabel property. */ private static var _initializingLabel:String = ""Initializing""; /** * The string to display as the label while in the initializing phase. * * @default ""Initializing"" * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public static function get initializingLabel():String { return _initializingLabel; } /** * @private */ public static function set initializingLabel(value:String):void { _initializingLabel = value; } //---------------------------------- // label //---------------------------------- /** * @private * Storage for the label property. */ private var _label:String = """"; /** * Text to display when the progress bar is active. * The Preloader class sets this value * before displaying the progress bar. * Implementing this property in a subclass is optional. * * @default """" * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get label():String { return _label; } /** * @private */ protected function set label(value:String):void { if (!(value is Function)) _label = value; draw(); } //---------------------------------- // labelFormat //---------------------------------- /** * The TextFormat object of the TextField component of the label. * This is a read-only property which you must override * if you need to change it. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get labelFormat():TextFormat { var tf:TextFormat = new TextFormat(); tf.color = 0x333333; tf.font = ""Verdana""; tf.size = 10; return tf; } //---------------------------------- // labelRect //---------------------------------- /** * The dimensions of the TextField component for the label. * This is a read-only property which you must override * if you need to change it. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get labelRect():Rectangle { return new Rectangle(14, 17, 100, 16); } //---------------------------------- // percentFormat //---------------------------------- /** * The TextFormat of the TextField component for displaying the percent. * This is a read-only property which you must override * if you need to change it. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get percentFormat():TextFormat { var tf:TextFormat = new TextFormat(); tf.align = ""right""; tf.color = 0x000000; tf.font = ""Verdana""; tf.size = 10; return tf; } //---------------------------------- // percentRect //---------------------------------- /** * The dimensions of the TextField component for displaying the percent. * This is a read-only property which you must override * if you need to change it. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get percentRect():Rectangle { return new Rectangle(108, 4, 34, 16); } //---------------------------------- // showLabel //---------------------------------- /** * @private * Storage for the showLabel property. */ private var _showLabel:Boolean = true; /** * Controls whether to display the label, true, * or not, false. * * @default true * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get showLabel():Boolean { return _showLabel; } /** * @private */ protected function set showLabel(value:Boolean):void { _showLabel = value; draw(); } //---------------------------------- // showPercentage //---------------------------------- /** * @private * Storage for the showPercentage property. */ private var _showPercentage:Boolean = false; /** * Controls whether to display the percentage, true, * or not, false. * * @default true * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get showPercentage():Boolean { return _showPercentage; } /** * @private */ protected function set showPercentage(value:Boolean):void { _showPercentage = value; draw(); } //-------------------------------------------------------------------------- // // Methods:IPreloaderDisplay // //-------------------------------------------------------------------------- /** * Called by the Preloader after the download progress bar * has been added as a child of the Preloader. * This should be the starting point for configuring your download progress bar. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function initialize():void { _startTime = getTimer(); center(stageWidth, stageHeight); } //-------------------------------------------------------------------------- // // Methods // //-------------------------------------------------------------------------- /** * Centers the download progress bar based on the passed in dimensions. * * @param width The width of the area in which to center the download progress bar. * * @param height The height of the area in which to center the download progress bar. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function center(width:Number, height:Number):void { _xOffset = Math.floor((width - _borderRect.width) / 2); _yOffset = Math.floor((height - _borderRect.height) / 2); } /** * @private * Updates the display. */ private function draw():void { var percentage:Number; if (_startedLoading) { if (!_startedInit) { // 0 to MaxDL Percentage percentage = Math.round(getPercentLoaded(_value, _maximum) * DOWNLOAD_PERCENTAGE / 100); } else { // MaxDL percentage to 100 percentage = Math.round((getPercentLoaded(_value, _maximum) * (100 - DOWNLOAD_PERCENTAGE) / 100) + DOWNLOAD_PERCENTAGE); } } else { percentage = getPercentLoaded(_value, _maximum); } if (_labelObj) _labelObj.text = _label; if (_percentObj) { if (!_showPercentage) { _percentObj.visible = false; _percentObj.text = """"; } else { _percentObj.text = String(percentage) + ""%""; } } if (_barSprite && _barFrameSprite) { if (!_showProgressBar) { _barSprite.visible = false; _barFrameSprite.visible = false; } else { drawProgressBar(percentage); } } } /** * Creates the subcomponents of the display. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function createChildren():void { var g:Graphics = graphics; var labelObj:TextField; var percentObj:TextField; // Draw the background first // Same value as StyleManager.NOT_A_COLOR. However, we don't want to bring in StyleManager at this point. if (backgroundColor != 0xFFFFFFFF) { g.beginFill(backgroundColor, backgroundAlpha); g.drawRect(0, 0, stageWidth, stageHeight); } if (backgroundImage != null) loadBackgroundImage(backgroundImage); _barFrameSprite = new Sprite(); _barSprite = new Sprite(); addChild(_barFrameSprite); addChild(_barSprite); // Draw the outside border and fill. g.beginFill(0xCCCCCC, 0.4); g.drawRoundRect(calcX(_borderRect.x), calcY(_borderRect.y), _borderRect.width, _borderRect.height, _borderRect.cornerRadius * 2, _borderRect.cornerRadius * 2); g.drawRoundRect(calcX(_borderRect.x + 1), calcY(_borderRect.y + 1), _borderRect.width - 2, _borderRect.height - 2, _borderRect.cornerRadius - 1 * 2, _borderRect.cornerRadius - 1 * 2); g.endFill(); g.beginFill(0xCCCCCC,0.4); g.drawRoundRect(calcX(_borderRect.x + 1), calcY(_borderRect.y + 1), _borderRect.width - 2, _borderRect.height - 2, _borderRect.cornerRadius - 1 * 2, _borderRect.cornerRadius - 1 * 2); g.endFill(); var frame_g:Graphics = _barFrameSprite.graphics; // Draw the bar frame border and fill var matrix:Matrix = new Matrix(); matrix.createGradientBox(_barFrameRect.width, _barFrameRect.height, Math.PI / 2, calcX(_barFrameRect.x), calcY(_barFrameRect.y)); frame_g.beginGradientFill(GradientType.LINEAR, [ 0x5C6266, 0xB5B8BA ], [ 1.0, 1.0 ], [ 0, 0xFF ], matrix); frame_g.drawRoundRect(calcX(_barFrameRect.x), calcY(_barFrameRect.y), _barFrameRect.width, _barFrameRect.height, _barFrameRect.cornerRadius * 2, _barFrameRect.cornerRadius * 2); frame_g.drawRoundRect(calcX(_barFrameRect.x + 1), calcY(_barFrameRect.y + 1), _barFrameRect.width - 2, _barFrameRect.height - 2, _barFrameRect.cornerRadius * 2, _barFrameRect.cornerRadius * 2); frame_g.endFill(); // Attach the label TextField. _labelObj = new TextField(); _labelObj.x = calcX(_labelRect.x); _labelObj.y = calcY(_labelRect.y); _labelObj.width = _labelRect.width; _labelObj.height = _labelRect.height; _labelObj.selectable = false; _labelObj.defaultTextFormat = labelFormat; addChild(_labelObj); // Attach the percentage TextField. _percentObj = new TextField(); _percentObj.x = calcX(_percentRect.x); _percentObj.y = calcY(_percentRect.y); _percentObj.width = _percentRect.width; _percentObj.height = _percentRect.height; _percentObj.selectable = false; _percentObj.defaultTextFormat = percentFormat; addChild(_percentObj); // Create dropshadow var ds:RectangularDropShadow = new RectangularDropShadow(); ds.color = 0x000000; ds.angle = 90; ds.alpha = .6; ds.distance = 2; ds.tlRadius = ds.trRadius = ds.blRadius = ds.brRadius = _borderRect.cornerRadius; ds.drawShadow(g, calcX(_borderRect.x), calcY(_borderRect.y), _borderRect.width, _borderRect.height); // Draw the top line g.lineStyle(1,0xFFFFFF, .3); g.moveTo(calcX(_borderRect.x) + _borderRect.cornerRadius, calcY(_borderRect.y)); g.lineTo(calcX(_borderRect.x) - _borderRect.cornerRadius + _borderRect.width, calcY(_borderRect.y)); } /** * @private * Draws the progress bar. */ private function drawProgressBar(percentage:Number):void { var g:Graphics = _barSprite.graphics; g.clear(); var colors:Array = [ 0xFFFFFF, 0xFFFFFF ]; var ratios:Array = [ 0, 0xFF ]; var matrix:Matrix = new Matrix(); // Middle var barWidth:Number = _barRect.width * percentage / 100; var barWidthSplit:Number = barWidth / 2; var barHeight:Number = _barRect.height-4; var barX:Number = calcX(_barRect.x); var barY:Number = calcY(_barRect.y) + 2; var barY2:Number; matrix.createGradientBox(barWidthSplit, barHeight, 0, barX, barY); g.beginGradientFill(GradientType.LINEAR, colors, [ .39, .85], ratios, matrix); g.drawRect(barX, barY, barWidthSplit, barHeight); matrix.createGradientBox(barWidthSplit, barHeight, 0, barX + barWidthSplit, barY); g.beginGradientFill(GradientType.LINEAR, colors, [.85, 1.0], ratios, matrix); g.drawRect(barX + barWidthSplit, barY, barWidthSplit, barHeight); // Outer highlight barWidthSplit = barWidth / 3; barHeight = _barRect.height; barY = calcY(_barRect.y); barY2 = barY + barHeight - 1; matrix.createGradientBox(barWidthSplit, barHeight, 0, barX, barY); g.beginGradientFill(GradientType.LINEAR, colors, [ .05, .15], ratios, matrix); g.drawRect(barX, barY, barWidthSplit, 1); g.drawRect(barX, barY2, barWidthSplit, 1); matrix.createGradientBox(barWidthSplit, barHeight, 0, barX + barWidthSplit, barY); g.beginGradientFill(GradientType.LINEAR, colors, [ .15, .25], ratios, matrix); g.drawRect(barX + barWidthSplit, barY, barWidthSplit, 1); g.drawRect(barX + barWidthSplit, barY2, barWidthSplit, 1); matrix.createGradientBox(barWidthSplit, barHeight, 0, barX + barWidthSplit * 2, barY); g.beginGradientFill(GradientType.LINEAR, colors, [ .25, .1], ratios, matrix); g.drawRect(barX + barWidthSplit * 2, barY, barWidthSplit, 1); g.drawRect(barX + barWidthSplit * 2, barY2, barWidthSplit, 1); // Inner highlight barWidthSplit = barWidth / 3; barHeight = _barRect.height; barY = calcY(_barRect.y) + 1; barY2 = calcY(_barRect.y) + barHeight - 2; matrix.createGradientBox(barWidthSplit, barHeight, 0, barX, barY); g.beginGradientFill(GradientType.LINEAR, colors, [ .15, .30], ratios, matrix); g.drawRect(barX, barY, barWidthSplit, 1); g.drawRect(barX, barY2, barWidthSplit, 1); matrix.createGradientBox(barWidthSplit, barHeight, 0, barX + barWidthSplit, barY); g.beginGradientFill(GradientType.LINEAR, colors, [ .30, .40], ratios, matrix); g.drawRect(barX + barWidthSplit, barY, barWidthSplit, 1); g.drawRect(barX + barWidthSplit, barY2, barWidthSplit, 1); matrix.createGradientBox(barWidthSplit, barHeight, 0, barX + barWidthSplit * 2, barY); g.beginGradientFill(GradientType.LINEAR, colors, [ .40, .25], ratios, matrix); g.drawRect(barX + barWidthSplit * 2, barY, barWidthSplit, 1); g.drawRect(barX + barWidthSplit * 2, barY2, barWidthSplit, 1); } /** * Updates the display of the download progress bar * with the current download information. * A typical implementation divides the loaded value by the total value * and displays a percentage. * If you do not implement this method, you should create * a progress bar that displays an animation to indicate to the user * that a download is occurring. * *

The setProgress() method is only called * if the application is being downloaded from a remote server * and the application is not in the browser cache.

* * @param completed Number of bytes of the application SWF file * that have been downloaded. * * @param total Size of the application SWF file in bytes. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function setProgress(completed:Number, total:Number):void { if (!isNaN(completed) && !isNaN(total) && completed >= 0 && total > 0) { _value = Number(completed); _maximum = Number(total); draw(); } } /** * Returns the percentage value of the application loaded. * * @param loaded Number of bytes of the application SWF file * that have been downloaded. * * @param total Size of the application SWF file in bytes. * * @return The percentage value of the loaded application. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function getPercentLoaded(loaded:Number, total:Number):Number { var perc:Number; if (loaded == 0 || total == 0 || isNaN(total) || isNaN(loaded)) return 0; else perc = 100 * loaded/total; if (isNaN(perc) || perc <= 0) return 0; else if (perc > 99) return 99; else return Math.round(perc); } /** * @private * Make the display class visible. */ private function show():void { _showingDisplay = true; calcScale(); draw(); _displayTime = getTimer(); // Time when the display is shown. } /** * @private */ private function hide():void { } /** * @private */ private function calcX(base:Number):Number { return base + _xOffset; } /** * @private */ private function calcY(base:Number):Number { return base + _yOffset; } /** * @private * Figure out the scale for the display class based on the stage size. * Then creates the children subcomponents. */ private function calcScale():void { if (stageWidth < 160 || stageHeight < 120) { scaleX = 1.0; scaleY = 1.0; } else if (stageWidth < 240 || stageHeight < 150) { // Scale to appropriate size createChildren(); var scale:Number = Math.min(stageWidth / 240.0, stageHeight / 150.0); scaleX = scale; scaleY = scale; } else { createChildren(); } } /** * Defines the algorithm for determining whether to show * the download progress bar while in the download phase. * * @param elapsedTime number of milliseconds that have elapsed * since the start of the download phase. * * @param event The ProgressEvent object that contains * the bytesLoaded and bytesTotal properties. * * @return If the return value is true, then show the * download progress bar. * The default behavior is to show the download progress bar * if more than 700 milliseconds have elapsed * and if Flex has downloaded less than half of the bytes of the SWF file. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function showDisplayForDownloading(elapsedTime:int, event:ProgressEvent):Boolean { return elapsedTime > 700 && event.bytesLoaded < event.bytesTotal / 2; } /** * Defines the algorithm for determining whether to show the download progress bar * while in the initialization phase, assuming that the display * is not currently visible. * * @param elapsedTime number of milliseconds that have elapsed * since the start of the download phase. * * @param count number of times that the initProgress event * has been received from the application. * * @return If true, then show the download progress bar. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function showDisplayForInit(elapsedTime:int, count:int):Boolean { return elapsedTime > 300 && count == 2; } /** * @private */ private function loadBackgroundImage(classOrString:Object):void { var cls:Class; // The ""as"" operator checks to see if classOrString // can be coerced to a Class if (classOrString && classOrString as Class) { // Load background image given a class pointer cls = Class(classOrString); initBackgroundImage(new cls()); } else if (classOrString && classOrString is String) { try { cls = Class(getDefinitionByName(String(classOrString))); } catch(e:Error) { // ignore } if (cls) { var newStyleObj:DisplayObject = new cls(); initBackgroundImage(newStyleObj); } else { // Loading the image is slightly different // than in Loader.loadContent()... is this on purpose? // Load background image from external URL var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener( Event.COMPLETE, loader_completeHandler); loader.contentLoaderInfo.addEventListener( IOErrorEvent.IO_ERROR, loader_ioErrorHandler); var loaderContext:LoaderContext = new LoaderContext(); loaderContext.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain); loader.load(new URLRequest(String(classOrString)), loaderContext); } } } /** * @private */ private function initBackgroundImage(image:DisplayObject):void { addChildAt(image,0); var backgroundImageWidth:Number = image.width; var backgroundImageHeight:Number = image.height; // Scale according to backgroundSize var percentage:Number = calcBackgroundSize(); if (isNaN(percentage)) { var sX:Number = 1.0; var sY:Number = 1.0; } else { var scale:Number = percentage * 0.01; sX = scale * stageWidth / backgroundImageWidth; sY = scale * stageHeight / backgroundImageHeight; } image.scaleX = sX; image.scaleY = sY; // Center everything. // Use a scrollRect to position and clip the image. var offsetX:Number = Math.round(0.5 * (stageWidth - backgroundImageWidth * sX)); var offsetY:Number = Math.round(0.5 * (stageHeight - backgroundImageHeight * sY)); image.x = offsetX; image.y = offsetY; // Adjust alpha to match backgroundAlpha if (!isNaN(backgroundAlpha)) image.alpha = backgroundAlpha; } /** * @private */ private function calcBackgroundSize():Number { var percentage:Number = NaN; if (backgroundSize) { var index:int = backgroundSize.indexOf(""%""); if (index != -1) percentage = Number(backgroundSize.substr(0, index)); } return percentage; } //-------------------------------------------------------------------------- // // Event handlers // //-------------------------------------------------------------------------- /** * Event listener for the ProgressEvent.PROGRESS event. * This implementation updates the progress bar * with the percentage of bytes downloaded. * * @param event The event object. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function progressHandler(event:ProgressEvent):void { var loaded:uint = event.bytesLoaded; var total:uint = event.bytesTotal; var elapsedTime:int = getTimer() - _startTime; // Only show the Loading phase if it will appear for awhile. if (_showingDisplay || showDisplayForDownloading(elapsedTime, event)) { if (!_startedLoading) { show(); label = downloadingLabel; _startedLoading = true; } setProgress(event.bytesLoaded, event.bytesTotal); } } /** * Event listener for the Event.COMPLETE event. * The default implementation does nothing. * * @param event The event object. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function completeHandler(event:Event):void { } /** * Event listener for the RSLEvent.RSL_PROGRESS event. * The default implementation does nothing. * * @param event The event object. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function rslProgressHandler(event:RSLEvent):void { } /** * Event listener for the RSLEvent.RSL_COMPLETE event. * * @param event The event object. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function rslCompleteHandler(event:RSLEvent):void { var word:String = ""library""; if (event.isResourceModule) word = ""module""; label = ""Loaded "" + word + "" "" + event.rslIndex + "" of "" + event.rslTotal; } /** * Event listener for the RSLEvent.RSL_ERROR event. * This event listner handles any errors detected when downloading an RSL. * * @param event The event object. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function rslErrorHandler(event:RSLEvent):void { _preloader.removeEventListener(ProgressEvent.PROGRESS, progressHandler); _preloader.removeEventListener(Event.COMPLETE, completeHandler); _preloader.removeEventListener(RSLEvent.RSL_PROGRESS, rslProgressHandler); _preloader.removeEventListener(RSLEvent.RSL_COMPLETE, rslCompleteHandler); _preloader.removeEventListener(RSLEvent.RSL_ERROR, rslErrorHandler); _preloader.removeEventListener(FlexEvent.INIT_PROGRESS, initProgressHandler); _preloader.removeEventListener(FlexEvent.INIT_COMPLETE, initCompleteHandler); if (!_showingDisplay) { show(); _showingDisplay = true; } label = ""RSL Error "" + (event.rslIndex + 1) + "" of "" + event.rslTotal; var errorField:ErrorField = new ErrorField(this); errorField.show(event.errorText); } /** * @private * Helper function that dispatches the Complete event to the preloader. * * @param event The event object. */ private function timerHandler(event:Event = null):void { dispatchEvent(new Event(Event.COMPLETE)); } /** * Event listener for the FlexEvent.INIT_PROGRESS event. * This implementation updates the progress bar * each time the event is dispatched, and changes the text of the label. * * @param event The event object. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function initProgressHandler(event:Event):void { var elapsedTime:int = getTimer() - _startTime; _initProgressCount++; if (!_showingDisplay && showDisplayForInit(elapsedTime, _initProgressCount)) { _displayStartCount = _initProgressCount; show(); } if (_showingDisplay) { if (!_startedInit) { // First init progress event. _startedInit = true; label = initializingLabel; } var loaded:Number = 100 * _initProgressCount / (initProgressTotal - _displayStartCount); setProgress(Math.min(loaded, 100), 100); } } /** * Event listener for the FlexEvent.INIT_COMPLETE event. * * @param event The event object. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function initCompleteHandler(event:Event):void { var elapsedTime:int = getTimer() - _displayTime; if (_showingDisplay && elapsedTime < MINIMUM_DISPLAY_TIME) { var timer:Timer = new Timer(MINIMUM_DISPLAY_TIME - elapsedTime, 1); timer.addEventListener(TimerEvent.TIMER, timerHandler); timer.start(); } else { timerHandler(); } } /** * @private */ private function loader_completeHandler(event:Event):void { var target:DisplayObject = DisplayObject(LoaderInfo(event.target).loader); initBackgroundImage(target); } private function loader_ioErrorHandler(event:IOErrorEvent):void { // Swallow the error } } } import flash.display.DisplayObject; import flash.display.Sprite; import flash.text.TextField; import flash.text.TextFormat; import flash.system.Capabilities; import flash.text.TextFieldAutoSize; import flash.display.DisplayObjectContainer; import flash.display.Stage; import mx.preloaders.DownloadProgressBar; //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * @private * * Area to display error messages to help debug startup problems. * */ class ErrorField extends Sprite { private var downloadProgressBar:DownloadProgressBar; private const MIN_WIDTH_INCHES:int = 2; // min width of error message in inches private const MAX_WIDTH_INCHES:int = 6; // max width of error message in inches private const TEXT_MARGIN_PX:int = 10; //---------------------------------- // labelFormat //---------------------------------- /** * The TextFormat object of the TextField component of the label. * This is a read-only property which you must override * if you need to change it. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ protected function get labelFormat():TextFormat { var tf:TextFormat = new TextFormat(); tf.color = 0x000000; tf.font = ""Verdana""; tf.size = 10; return tf; } /** * @private * * @param - parent - parent of the error field. */ public function ErrorField(downloadProgressBar:DownloadProgressBar) { super(); this.downloadProgressBar = downloadProgressBar; } /** * Create and show the error message. * * @param errorText - text for error message. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function show(errorText:String):void { if (errorText == null || errorText.length == 0) return; var screenWidth:Number = downloadProgressBar.stageWidth; var screenHeight:Number = downloadProgressBar.stageHeight; // create the text field for the message and // add it to the parent. var textField:TextField = new TextField(); textField.autoSize = TextFieldAutoSize.LEFT; textField.multiline = true; textField.wordWrap = true; textField.background = true; textField.defaultTextFormat = labelFormat; textField.text = errorText; textField.width = Math.max(MIN_WIDTH_INCHES * Capabilities.screenDPI, screenWidth - (TEXT_MARGIN_PX * 2)); textField.width = Math.min(MAX_WIDTH_INCHES * Capabilities.screenDPI, textField.width); textField.y = Math.max(0, screenHeight - TEXT_MARGIN_PX - textField.height); // center field horizontally textField.x = (screenWidth - textField.width) / 2; downloadProgressBar.parent.addChild(this); this.addChild(textField); } } ",12346,True,2555.359394353211,median "package { import away3d.containers.*; import away3d.core.math.MathConsts; import Box2D.Collision.Shapes.b2CircleShape; import Box2D.Collision.Shapes.b2PolygonShape; import Box2D.Collision.Shapes.b2Shape; import Box2D.Common.Math.b2Vec2; import Box2D.Dynamics.b2Body; import Box2D.Dynamics.b2BodyDef; import Box2D.Dynamics.b2ContactListener; import Box2D.Dynamics.b2Fixture; import Box2D.Dynamics.b2FixtureDef; import Box2D.Dynamics.b2World; import Box2D.Dynamics.Contacts.b2Contact; import com.noteflight.standingwave3.filters.ResamplingFilter; import flash.media.SoundChannel; import flash.media.SoundMixer; import flash.media.SoundTransform; import flash.net.SharedObject; import flash.ui.Multitouch; import flash.ui.MultitouchInputMode; import com.noteflight.standingwave3.elements.*; import com.noteflight.standingwave3.output.*; import com.noteflight.standingwave3.sources.*; import com.noteflight.standingwave3.filters.GainFilter; import com.noteflight.standingwave3.filters.EchoFilter; import flash.geom.Point; import flash.geom.Rectangle; import flash.media.Sound; import Game.GeneralObject; import Game.Player; import starling.animation.Tween; import away3d.core.managers.Stage3DManager; import away3d.core.managers.Stage3DProxy; import away3d.entities.*; import away3d.events.LoaderEvent; import away3d.events.Stage3DEvent; import away3d.loaders.Loader3D; import away3d.loaders.misc.AssetLoaderContext; import away3d.loaders.parsers.OBJParser; import away3d.materials.*; import away3d.primitives.*; import away3d.utils.*; import flash.net.URLLoader; import flash.net.URLRequest; import flash.text.engine.TextBlock; import starling.core.*; import flash.display.*; import flash.events.*; import flash.geom.Vector3D; [SWF(backgroundColor=""#000000"", frameRate=""60"", quality=""LOW"")] [Frame(factoryClass='Preloader')] // name of preloader class public class Basic_View extends Sprite { // mug [Embed(source=""assets/models/mug/mug.obj"", mimeType=""application/octet-stream"")] private var MugModel:Class; [Embed(source=""assets/models/mug/mug.mtl"", mimeType=""application/octet-stream"")] private var MugMTL:Class; [Embed(source=""assets/models/mug/mug.jpg"", mimeType=""image/jpg"")] private var MugTexture:Class; [Embed(source=""assets/models/coin/coin.obj"", mimeType=""application/octet-stream"")] private var CoinModel:Class; [Embed(source=""assets/models/coin/coin.mtl"", mimeType=""application/octet-stream"")] private var CoinMTL:Class; [Embed(source=""assets/models/coin/coingold.jpg"", mimeType=""image/jpg"")] private var CoinGoldTexture:Class; [Embed(source=""assets/models/coin/coinsilver.jpg"", mimeType=""image/jpg"")] private var CoinSilverTexture:Class; [Embed(source=""assets/models/coin/coincopper.jpg"", mimeType=""image/jpg"")] private var CoinCopperTexture:Class; [Embed(source=""assets/models/star/star.obj"", mimeType=""application/octet-stream"")] private var StarModel:Class; [Embed(source=""assets/models/star/star.mtl"", mimeType=""application/octet-stream"")] private var StarMTL:Class; [Embed(source=""assets/models/star/star.png"", mimeType=""image/png"")] private var StarTexture:Class; [Embed(source=""assets/models/clock/clock.obj"", mimeType=""application/octet-stream"")] private var ClockModel:Class; [Embed(source=""assets/models/clock/clock.mtl"", mimeType=""application/octet-stream"")] private var ClockMTL:Class; [Embed(source=""assets/models/clock/clock.jpg"", mimeType=""image/jpg"")] private var ClockTexture:Class; [Embed(source=""assets/models/barstool/barstool.obj"", mimeType=""application/octet-stream"")] private var BarStoolModel:Class; [Embed(source=""assets/models/barstool/barstool.mtl"", mimeType=""application/octet-stream"")] private var BarStoolMTL:Class; [Embed(source=""assets/models/barstool/barstool_small.jpg"", mimeType=""image/jpg"")] private var BarStoolTexture:Class; [Embed(source=""assets/models/plant/plant.obj"", mimeType=""application/octet-stream"")] private var PlantModel:Class; [Embed(source=""assets/models/plant/plant.mtl"", mimeType=""application/octet-stream"")] private var PlantMTL:Class; [Embed(source=""assets/models/plant/plant.jpg"", mimeType=""image/jpg"")] private var PlantTexture:Class; [Embed(source=""assets/models/neon/neonskyline.obj"", mimeType=""application/octet-stream"")] private var NeonSkylineModel:Class; [Embed(source=""assets/models/neon/neonskyline.mtl"", mimeType=""application/octet-stream"")] private var NeonSkylineMTL:Class; [Embed(source=""assets/models/neon/neon.jpg"", mimeType=""image/jpg"")] private var NeonSkylineTexture:Class; [Embed(source=""assets/models/billards/pool.obj"", mimeType=""application/octet-stream"")] private var BillardsModel:Class; [Embed(source=""assets/models/billards/pool.mtl"", mimeType=""application/octet-stream"")] private var BillardsMTL:Class; [Embed(source=""assets/models/billards/pool.jpg"", mimeType=""image/jpg"")] private var BillardsTexture:Class; [Embed(source=""assets/models/counter/counter.obj"", mimeType=""application/octet-stream"")] private var CounterModel:Class; [Embed(source=""assets/models/counter/counter.mtl"", mimeType=""application/octet-stream"")] private var CounterMTL:Class; [Embed(source=""assets/models/counter/counter.jpg"", mimeType=""image/jpg"")] private var CounterTexture:Class; //plane texture [Embed(source=""assets/textures/floor_diffuse.jpg"")] public static var FloorDiffuse:Class; [Embed(source=""assets/textures/win.jpg"")] public static var FloorWin:Class; //plane texture [Embed(source=""assets/textures/grass_diffuse.jpg"")] public static var GrassDiffuse:Class; //plane texture [Embed(source=""assets/textures/checker.jpg"")] public static var CheckerFloorDiffuse:Class; [Embed(source=""assets/textures/bricks_small.jpg"")] public static var BricksDiffuse:Class; private var mouseAccelY:int = 0, mouseAccelX:int = 0; private var title_pan_cam:Number = 0, enteredLevel:Boolean = false; // Stage manager and proxy instances private var stage3DManager:Stage3DManager; private var stage3DProxy:Stage3DProxy; static public var sharedOBJ:SharedObject; static public var globalMouseX:int=0, globalMouseY:int=0; static public var playerX:int=0, playerY:int=0; static public var restart:Boolean = false; static private var _setLevel:int = -1; //private var starlingBackground:Starling; private var starlingForeground:Starling; //private var hoverController:HoverController; //engine variables private var _view:View3D; // physics public var world:b2World; static public var worldScale:Number = 0.04; // 2d private var hud:HUD, setuphud:Boolean = false; // scene objects private var _mug:Loader3D; private var _turtlegun:Loader3D; private var player:Player; public var cameraDisplacementMag:Number, cameraDirection:Number; static public var currentLevel:int = -1; // game logic public var lastLevel:int = -1; // if this is the same as the current level during loading, you can just use the reset nethod to avoid recreating the level geometry private var goal:int = 0, goal_reset:int = 90, inGoal:Boolean = false; private var keySpace:Boolean = false; static public var endLevel:Boolean=false, unloaded_solidlist:Array = new Array, solidlist:Array = new Array; // contains Rectangle bounding boxes of all solid objects private var stars:int = 0, coins:int = 0, totalcoins:int = 0; public var goallist:Array = new Array, coinsCollected:Array; public var pickuplist:Array = new Array; public var animationlist:Array = new Array; public var boxQueue:Array = new Array, floorQueue:Array = new Array, reloadMapData:Array, pickupQueue:Array = [new Array, new Array, new Array, new Array], pickupQueueInactive:Array = [new Array, new Array, new Array, new Array]; // gold coin, silver coin, copper count, star, same as the id property on pickups public var boxQueueActive:Array = new Array, floorQueueActive:Array = new Array; private var previewCourse:Boolean = true; private var faraway:int = -10000; // set object coordinates to faraway to get them off the screen private var audioplayer:AudioPlayer, audioplayer2:AudioPlayer, music:Sound, musicchannel:SoundChannel, music_updated:Boolean = true; private var sound_soda:IAudioSource, sound_coin:IAudioSource, sound_button:IAudioSource, sound_thud:IAudioSource, sound_thud2:IAudioSource, sound_coindrop:IAudioSource, sound_star:IAudioSource, sound_countdown:IAudioSource; static public var play_sound_coindrop:Boolean = false, play_sound_button:Boolean = false; // Textures private var gameWoodFloorTexture:TextureMaterial, gameWinFloorTexture:TextureMaterial, gameBoxDiffuse:TextureMaterial; //private var goldCoinTexture:TextureMaterial, silverCoinTexture:TextureMaterial, copperCoinTexture:TextureMaterial, starTexture:TextureMaterial; static public var room:int = 0; private var contactListener:ContactListener; private var tutorialmode:int = -1; public function getMainLoaderInfo():LoaderInfo { var loaderInfo:LoaderInfo = root.loaderInfo; if (loaderInfo.loader != null) { loaderInfo = loaderInfo.loader.loaderInfo; } return loaderInfo; } /** * Constructor */ public function Basic_View() { if (stage) init(null); else addEventListener(Event.ADDED_TO_STAGE, init); } static public function setLevel(lvl:int):void { _setLevel = lvl; } private function SetupScene():void { var textureMaterialWall:TextureMaterial = new TextureMaterial(Cast.bitmapTexture(BricksDiffuse)); var textureMaterial:TextureMaterial = new TextureMaterial(Cast.bitmapTexture(CheckerFloorDiffuse)); for (var xx:int = 0; xx < 12; xx++) { var wall:Mesh = new Mesh(new PlaneGeometry(800, 800), textureMaterialWall); wall.rotationX = -90; wall.x = -800 * 6 + xx * 800; wall.y = 0; wall.z = 800*3; _view.scene.addChild(wall); for (var yy:int = 0; yy < 7; yy++) { var plane:Mesh = new Mesh(new PlaneGeometry(800, 800), textureMaterial); plane.x = -800*6 + xx*800; plane.z = -800*3 + yy*800; plane.y = -400; _view.scene.addChild(plane); } } // place clock var clockLoaderContent:AssetLoaderContext = new AssetLoaderContext(); clockLoaderContent.mapUrlToData(""clock.mtl"", new ClockMTL()); clockLoaderContent.mapUrlToData(""clock.jpg"", new ClockTexture()); var _clock:Loader3D = new Loader3D(); _clock.scale(100); _clock.loadData(new ClockModel(), clockLoaderContent, null, new OBJParser(1)); _clock.y = 200; _clock.rotationY = 180; _clock.rotationX = 90; _clock.x = -400; _clock.z = 2400; _view.scene.addChild(_clock); var plantLoaderContent:AssetLoaderContext = new AssetLoaderContext(); plantLoaderContent.mapUrlToData(""plant.mtl"", new PlantMTL()); plantLoaderContent.mapUrlToData(""plant.jpg"", new PlantTexture()); var _plant:Loader3D = new Loader3D(); _plant.scale(250); _plant.loadData(new PlantModel(), plantLoaderContent, null, new OBJParser(1)); _plant.y = -420; _plant.rotationY = 70; _plant.x = 2200; _plant.z = 2000; _view.scene.addChild(_plant); var neonskylineLoaderContent:AssetLoaderContext = new AssetLoaderContext(); neonskylineLoaderContent.mapUrlToData(""neonskyline.mtl"", new NeonSkylineMTL()); neonskylineLoaderContent.mapUrlToData(""neon.jpg"", new NeonSkylineTexture()); var _neon:Loader3D = new Loader3D(); _neon.scale(80); _neon.loadData(new NeonSkylineModel(), neonskylineLoaderContent, null, new OBJParser(1)); _neon.rotationX = -90; _neon.y = -100; _neon.x = 1100; _neon.z = 2350; _view.scene.addChild(_neon); var billardsLoaderContent:AssetLoaderContext = new AssetLoaderContext(); billardsLoaderContent.mapUrlToData(""pool.mtl"", new BillardsMTL()); billardsLoaderContent.mapUrlToData(""pool.jpg"", new BillardsTexture()); var _billards:Loader3D = new Loader3D(); _billards.scale(200); _billards.loadData(new BillardsModel(), billardsLoaderContent, null, new OBJParser(1)); _billards.rotationY = 180; _billards.y = -400; _billards.x = -2800; _billards.z = 600; _view.scene.addChild(_billards); // set chairs up for (var yy:int = 0; yy < 8; yy++) { var barstoolLoaderContent:AssetLoaderContext = new AssetLoaderContext(); barstoolLoaderContent.mapUrlToData(""barstool.mtl"", new BarStoolMTL()); barstoolLoaderContent.mapUrlToData(""barstool.jpg"", new BarStoolTexture()); var _stool:Loader3D = new Loader3D(); _stool.scale(140); _stool.loadData(new BarStoolModel(), barstoolLoaderContent, null, new OBJParser(1)); _stool.y = -400; _stool.x = 2400; _stool.z = -(450*4) + 450 * yy; _view.scene.addChild(_stool); } // make tables for (var yy:int = 0; yy < 4; yy++) { var counterLoaderContent:AssetLoaderContext = new AssetLoaderContext(); counterLoaderContent.mapUrlToData(""counter.mtl"", new CounterMTL()); counterLoaderContent.mapUrlToData(""counter.jpg"", new CounterTexture()); var _counter:Loader3D = new Loader3D(); _counter.scale(226); _counter.loadData(new CounterModel(), counterLoaderContent, null, new OBJParser(1)); _counter.rotationY = 90; _counter.y = -400; _counter.x = 2900; _counter.z = -(900*1.55) + 900 * yy; _view.scene.addChild(_counter); } } private function loadTextureMaterials():void { gameWoodFloorTexture = new TextureMaterial(Cast.bitmapTexture(GrassDiffuse)); gameWinFloorTexture = new TextureMaterial(Cast.bitmapTexture(FloorWin)); gameBoxDiffuse = new TextureMaterial(Cast.bitmapTexture(FloorDiffuse)); } private function loadQueues():void { for (var i:int = 0; i < 200; i++) { var floor:Mesh = new Mesh(new PlaneGeometry(200, 200, 1, 1), null); floor.x = floor.y = floor.z = faraway; floorQueue.push(floor); } for (var i:int = 0; i < 200; i++) { var box:Mesh = new Mesh(new CubeGeometry(200, 200, 200, 1, 1, 1), null); box.x = box.y = box.z = faraway; boxQueue.push(box); } for (var ii:int = 0; ii < 12; ii++) { for (var i:int = 0; i < 3; i++) { var coinLoaderContent:AssetLoaderContext = new AssetLoaderContext(); coinLoaderContent.mapUrlToData(""coin.mtl"", new CoinMTL()); var scaleMultiplier:Number; switch (i) { case 0: coinLoaderContent.mapUrlToData(""coingold.jpg"", new CoinGoldTexture()); scaleMultiplier = 1.0; break; case 1: coinLoaderContent.mapUrlToData(""coingold.jpg"", new CoinSilverTexture()); scaleMultiplier = 0.9; break; case 2: coinLoaderContent.mapUrlToData(""coingold.jpg"", new CoinCopperTexture()); scaleMultiplier = 0.6; break; } var _coin:Loader3D = new Loader3D(); _coin.loadData(new CoinModel(), coinLoaderContent, null, new OBJParser(1)); _coin.scale(45 * scaleMultiplier); _coin.y = 70; _coin.x = _coin.y = faraway; pickupQueueInactive[i].push(_coin); } } for (var i:int = 0; i < 3; i++) { var starLoaderContent:AssetLoaderContext = new AssetLoaderContext(); starLoaderContent.mapUrlToData(""star.mtl"", new StarMTL()); starLoaderContent.mapUrlToData(""star.png"", new StarTexture()); var _star:Loader3D = new Loader3D(); _star.loadData(new StarModel(), starLoaderContent, null, new OBJParser(1)); _star.scale(60); _star.y = 70; _star.x = _star.z = faraway; pickupQueueInactive[3].push(_star); } } private function resetVariables():void { goal = goal_reset; endLevel = false; coins = 0; stars = 0; coinsCollected = [0, 0, 0]; } private function preLevelSetup():void { resetVariables(); if (hud!=null) hud.Reset(); solidlist = new Array(); goallist = new Array(); animationlist = new Array(); pickuplist = new Array(); reloadMapData = new Array(); // data to be used for reloading a level, will look like: [player.x, player.y, moves, pickuip1.id, pickup1.x, pickup1.y, pickup2.id, ....] totalcoins = 0; while (floorQueueActive.length > 0) { var floor:Mesh = floorQueueActive.pop() _view.scene.removeChild(floor); floor.x = floor.y = floor.z = faraway; floorQueue.push(floor); } while (boxQueueActive.length > 0) { var box:Mesh = boxQueueActive.pop() _view.scene.removeChild(box); box.x = box.y = box.z = faraway; boxQueue.push(box); } for (var i:int = 0; i < 4; i++) { while (pickupQueue[i].length > 0) { var c:Loader3D = pickupQueue[i].pop(); _view.scene.removeChild(c); pickupQueueInactive[i].push(c); } } world = new b2World(new b2Vec2(0, 0), false); /// try setting to true if (contactListener == null) { contactListener = new ContactListener(); contactListener.eventDispatcher.addEventListener(ContactListener.MUG_HIT_BLOCK, onMugHitBlock); } world.SetContactListener(contactListener); } private function onMugHitBlock(e:Event):void { if (Global.sound) { var thud:IAudioSource; var velocity:Number = player.body.GetLinearVelocity().Length(); if (velocity > 100) velocity = 100; if (velocity < 60) { //sound_thud2.resetPosition(); var thud:IAudioSource = new GainFilter(sound_thud2, -3*(velocity / 100.0)); //var thud_echo:IAudioSource = new EchoFilter(sound_thud2, 1.0, 0.5, 0.5); } else { //sound_thud.resetPosition(); var thud:IAudioSource = new GainFilter(sound_thud, -3*(velocity / 100.0)); } audioplayer.play(thud); } } private function loadLevel(lvl:int = 0):void { if (lvl == lastLevel) { restartLevel(); return; } preLevelSetup(); var levelData:XML; switch (lvl) { case 0: levelData = new XML(new Assets.Level1); break; case 1: levelData = new XML(new Assets.Level2); break; case 2: levelData = new XML(new Assets.Level3); break; case 3: levelData = new XML(new Assets.Level4); break; case 4: levelData = new XML(new Assets.Level5); break; case 5: levelData = new XML(new Assets.Level6); break; case 6: levelData = new XML(new Assets.Level7); break; case 7: levelData = new XML(new Assets.Level8); break; case 8: levelData = new XML(new Assets.Level9); break; case 9: levelData = new XML(new Assets.Level10); break; case 10: levelData = new XML(new Assets.Level11); break; case 11: levelData = new XML(new Assets.Level12); break; case 12: levelData = new XML(new Assets.Level13); break; case 13: levelData = new XML(new Assets.Level14); break; case 14: levelData = new XML(new Assets.Level15); break; case 15: levelData = new XML(new Assets.Level16); break; case 16: levelData = new XML(new Assets.Level17); break; case 17: levelData = new XML(new Assets.Level18); break; case 18: levelData = new XML(new Assets.Level19); break; case 19: levelData = new XML(new Assets.Level20); break; case 20: levelData = new XML(new Assets.Level21); break; case 21: levelData = new XML(new Assets.Level22); break; case 22: levelData = new XML(new Assets.Level23); break; case 23: levelData = new XML(new Assets.Level24); break; } if (lastLevel == 0 && hud != null) { hud.tutorial(-1); } lastLevel = currentLevel = lvl; tutorialmode = (currentLevel == 0 ? 0 : -1); // parse var o:XML; var w:int, h:int, d:int, segw:int, segh:int; for each (o in levelData.FLOOR[0].TILE) { var plane:Mesh = floorQueue.pop(); switch (int(o.@tex)) { case 1: plane.material = gameWoodFloorTexture; break; case 2: plane.material = gameWinFloorTexture; break; } //plane.material = textureMaterial; plane.x = o.@x; plane.y = o.@y; plane.z = o.@z; floorQueueActive.push(plane); } for each (o in levelData.WALL[0].BLOCK) { //var textureMaterial:TextureMaterial; var box:Mesh = boxQueue.pop(); switch (o.@tex) { case 1: box.material = gameBoxDiffuse; break; default: box.material = gameBoxDiffuse; } //box.material = textureMaterial; box.x = o.@x; box.y = o.@y; box.z = o.@z; boxQueueActive.push(box); var b2boxDef:b2BodyDef = new b2BodyDef(); b2boxDef.type = b2Body.b2_staticBody; b2boxDef.position = new b2Vec2(box.x * worldScale, box.z * worldScale); var b2box:b2Body = world.CreateBody(b2boxDef); var fixtureDef:b2FixtureDef = new b2FixtureDef(); fixtureDef.shape = b2PolygonShape.AsBox(100 * worldScale, 100 * worldScale); var fixture:b2Fixture = b2box.CreateFixture(fixtureDef); b2box.SetUserData(""block""); solidlist.push(new Rectangle(box.x-100, box.z-100, 200, 200)); } for each (o in levelData.GOALS[0].GOAL) { var go:GeneralObject = new GeneralObject(o.@x, o.@z, o.@w, o.@h); goallist.push(go); } for each (o in levelData.COINS[0].COIN) { var id:int = o.@id; var _coin:Loader3D = pickupQueueInactive[id-1].pop(); switch (id) { case 1: totalcoins += 25; break; case 2: totalcoins += 10; break; case 3: totalcoins++; break; } _coin.visible = true; _coin.y = 70; _coin.x = o.@x; _coin.z = o.@z; pickupQueue[id - 1].push(_coin); _view.scene.addChild(_coin); var _coinContainer:GeneralObject = new GeneralObject(o.@x, o.@z, 64, 64); _coinContainer.model = _coin; _coinContainer.id = id - 1; pickuplist.push(_coinContainer); } for each (o in levelData.STARS[0].STAR) { var _star:Loader3D = pickupQueueInactive[3].pop(); _star.y = 70; _star.x = o.@x; _star.z = o.@z; _star.visible = true; pickupQueue[3].push(_star); _view.scene.addChild(_star); var _starContainer:GeneralObject = new GeneralObject(o.@x, o.@z, 64, 64); _starContainer.model = _star; _starContainer.id = 3; pickuplist.push(_starContainer); } //if (player.body==null) { var b2mugDef:b2BodyDef = new b2BodyDef(); b2mugDef.type = b2Body.b2_dynamicBody; b2mugDef.awake = true; b2mugDef.inertiaScale = 0.5; b2mugDef.angularDamping = 2.0; b2mugDef.position = new b2Vec2(player.x * worldScale,player.y * worldScale); var b2mug:b2Body = world.CreateBody(b2mugDef); var fixtureDef:b2FixtureDef = new b2FixtureDef(); fixtureDef.shape = new b2CircleShape(player.w / 2 * worldScale); fixtureDef.restitution = 0.8; fixtureDef.density = 0.1; var fixture:b2Fixture = b2mug.CreateFixture(fixtureDef); b2mug.SetLinearDamping(1.1); b2mug.SetUserData(""mug""); player.body = b2mug; //} for (var i:int = 0; i < floorQueueActive.length; i++) { _view.scene.addChild(floorQueueActive[i]); } for (var i:int = 0; i < boxQueueActive.length; i++) { _view.scene.addChild(boxQueueActive[i]); } for each (o in levelData.PROPERTIES) { if (o.hasOwnProperty(""@moves"")) { player.moves = o.@moves; } if (o.hasOwnProperty(""@px"") && o.hasOwnProperty(""@py"")) { player.body.SetPosition(new b2Vec2(int(o.@px) * worldScale, int(o.@py)* worldScale)); } } reloadMapData = [player.body.GetPosition().x, player.body.GetPosition().y, player.moves]; for (var i:int = 0; i < pickuplist.length; i++) { reloadMapData.push(pickuplist[i].id); reloadMapData.push(pickuplist[i].x); reloadMapData.push(pickuplist[i].y); } cameraDisplacementMag = 0; previewCourse = false; setuphud = true; /* // collision debug code for (var i:int = 0; i < 1000; i++) { var box:Mesh = new Mesh(new CubeGeometry(4, 4, 4, 1, 1, 1)); var good:Boolean = false; var x:int, y:int; do { x = -2000 + Math.random() * 4000; y = -1600 + Math.random() * 3200; good = collideWithSolids(new Rectangle(x, y, 4, 4)); } while (!good); box.x = x; box.z = y; box.y = 24; _view.scene.addChild(box); }*/ } private function restartLevel():void { var next:Array = [0, 0, 0, 0]; pickuplist = new Array(); player.body.SetPosition(new b2Vec2(reloadMapData[0], reloadMapData[1])); player.body.SetLinearVelocity(new b2Vec2(0, 0)); player.moves = reloadMapData[2]; if (hud!=null) {hud.Reset();} while (animationlist.length > 0) { var ani:AnimationContainer = animationlist.pop(); if (ani.model!=null) { ani.model.rotationX = 0; ani.model.rotationZ = 0; ani.model = null; } //pickupQueue[ani.id].push(ani.model); } var id:int, size:int = 64; for (var i:int = 3; i < reloadMapData.length; i+=3) { id = int(reloadMapData[i]); //size = (id == 3 ? 56 : 48); var g:GeneralObject = new GeneralObject(reloadMapData[i+1], reloadMapData[i+2], size, size); g.id = id; g.model = pickupQueue[id][next[id]]; next[id]++; g.model.visible = true; g.model.x = g.x; g.model.z = g.y; g.model.y = 70; if (hud!=null) {hud.add_coin(g.x, g.y, g.id);} pickuplist.push(g); } resetVariables(); if (currentLevel == 0) { tutorialmode = 0; if (hud!=null) {hud.tutorial(0);} } restart = false; } private function init(e:Event):void { if (hasEventListener(Event.ADDED_TO_STAGE)) { removeEventListener(Event.ADDED_TO_STAGE, init); } sharedOBJ = SharedObject.getLocal(""rbslider_saved""); // Setup for handling Away3D and Starling Interoperation stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT; initProxies(); } private function initProxies():void { // Code from starling/away3d interoperability example // Define a new Stage3DManager for the Stage3D objects stage3DManager = Stage3DManager.getInstance(stage); // Create a new Stage3D proxy to contain the separate views stage3DProxy = stage3DManager.getFreeStage3DProxy(); stage3DProxy.addEventListener(Stage3DEvent.CONTEXT3D_CREATED, onContextCreated); stage3DProxy.antiAlias = 2; stage3DProxy.color = 0x0; } private function onContextCreated(event:Stage3DEvent):void { //Tweener.init(); // The Tweener library is fantastic but not used in this project if (checkDomain("""")) { initAway3D(); initStarling(); initAway3DScene(); // Used for site locking: //if (stage.loaderInfo.url.indexOf(""codeinferno.com"")!=-1) { initListeners(); //} onResize(); } } public function checkDomain (allowed:*):Boolean { var url:String = stage.loaderInfo.url; var startCheck:int = url.indexOf('://' ) + 3; if (url.substr(0, startCheck) == 'file://') return true; var domainLen:int = url.indexOf('/', startCheck) - startCheck; var host:String = url.substr(startCheck, domainLen); if (allowed is String) allowed = [allowed]; for each (var d:String in allowed) { if (host.substr(-d.length, d.length) == d) return true; } return false; } private function initAway3D() : void { _view = new View3D(); _view.stage3DProxy = stage3DProxy; _view.shareContext = true; addChild(_view); } private function initAway3DScene() : void { //setup the camera _view.camera.x = 0; _view.camera.z = -400; _view.camera.y = 1000; _view.camera.lookAt(new Vector3D()); //setup the scene var mugLoaderContent:AssetLoaderContext = new AssetLoaderContext(); mugLoaderContent.mapUrlToData(""mug.mtl"", new MugMTL()); mugLoaderContent.mapUrlToData(""mug.jpg"", new MugTexture()); _mug = new Loader3D(); _mug.name = ""mug""; _mug.scale(75); _mug.loadData(new MugModel(), mugLoaderContent, null, new OBJParser(1)); _mug.y = 10; _view.scene.addChild(_mug); player = new Player(); load(); loadTextureMaterials(); loadSounds(); loadQueues(); SetupScene(); loadLevel(0); musicchannel.soundTransform = new SoundTransform(Global.music ? 1 : 0); } /** * Initialise the Starling sprites */ private function initStarling() : void { // Create the Starling scenes //starlingBackground = new Starling(StarlingBackground, stage, stage3DProxy.viewPort, stage3DProxy.stage3D); Starling.handleLostContext = true; starlingForeground = new Starling(StarlingForeground, stage, stage3DProxy.viewPort, stage3DProxy.stage3D); starlingForeground.antiAliasing = 2; starlingForeground.start(); } private function initListeners():void { //stage.addEventListener(Event.ENTER_FRAME, onEnterFrame); stage.addEventListener(Event.ENTER_FRAME, _onEnterFrame, false,0, true); //stage.addEventListener(Event.RESIZE, onResize); _view.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false,0, true); _view.addEventListener(MouseEvent.MOUSE_UP, onMouseUp, false,0, true); stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyboardDown, false,0, true); stage.addEventListener(KeyboardEvent.KEY_UP, onKeyboardUp, false,0, true); //stage.addEventListener(Event.ACTIVATE, onActivate); stage.addEventListener(Event.DEACTIVATE, onDeactivate, false,0, true); } /** * Main render loop */ private function _onEnterFrame(e:Event):void { if (Global.music!=music_updated) { musicchannel.soundTransform = new SoundTransform(Global.music ? 1 : 0); music_updated = Global.music; } if (play_sound_button) { if (Global.sound) { sound_button.resetPosition(); audioplayer.play(sound_button); } play_sound_button = false; } /// Game logic if (room==2) { updateInGame(); } else if (room == 0 || !enteredLevel) { if (pickupQueue.length > 0) { if (pickupQueue[0][0].visible) { for (var i:int = 0; i < 4; i++) { for (var ii:int = 0; ii < pickupQueue[i].length; ii++) { pickupQueue[i][ii].visible = false; } } } } title_pan_cam += 0.001; if (title_pan_cam > 2) title_pan_cam -= 2; _view.camera.x = -2000 + (title_pan_cam < 1 ? title_pan_cam : (2-title_pan_cam)) * 4300; _view.camera.z = 1500 - ((title_pan_cam < 1 ? 0 : (title_pan_cam < 1.5? title_pan_cam-1 : 2-title_pan_cam)) * 4000); } else if (room == 1) { title_pan_cam = 0; } /// Render logic stage3DProxy.clear(); // Clear the Context3D object //starlingBackground.nextFrame(); if (_view!=null) {_view.render();} starlingForeground.nextFrame(); stage3DProxy.present(); // Present the Context3D object to Stage3D } private function updateHudBlocks():void { if (hud != null) { hud.clear_blocks(); var i:int; for (var i = 0; i < solidlist.length; i++) { hud.add_block(solidlist[i].x+100, solidlist[i].y+100); } for (var i = 0; i < goallist.length; i++) { hud.add_floor(goallist[i].x, goallist[i].y, 1); } for (var i = 0; i < floorQueueActive.length; i++) { hud.add_floor(floorQueueActive[i].x, floorQueueActive[i].z, 0); } } } /** * Game logic loop */ private function updateInGame():void { if (!enteredLevel) enteredLevel = true; if (hud != null) { hud.update(); hud.update_player(player.x, player.y); hud.update_stats(player.moves); } if (restart) { restartLevel(); } if (_setLevel != -1) { if (Global.sound) { sound_soda.resetPosition(); audioplayer.play(sound_soda); } loadLevel(_setLevel); _setLevel = -1; return; } if (tutorialmode!=-1 && hud!=null) { switch (tutorialmode) { case 0: hud.tutorial(0); tutorialmode = 1; break; case 1: if (player.body.GetLinearVelocity().Length() > 15) { if (hud != null) { hud.tutorial(1); } tutorialmode = 2; } break; case 2: if (inGoal) { if (hud != null) { hud.tutorial(2); } tutorialmode = 3; } break; } } if (play_sound_coindrop) { if (Global.sound) { sound_coindrop.resetPosition(); audioplayer.play(sound_coindrop); } play_sound_coindrop = false; } if (room != 2) return; if (endLevel) { if (player.drag) { player.drag = false; } } else if (Global.pause) { world.Step(0, 3, 3); return; } //_plane.rotationY += 1; player.update(); //crosshair.update(); world.Step(1.0/60.0, 3, 3); if (goal > 0) { inGoal = false; if (!player.drag && player.body.GetLinearVelocity().Length() < 4) { for (var i:int = 0; i < goallist.length; i++) { if ((new Rectangle(player.x - player.w / 2, player.y - player.h / 2, player.w, player.h)).intersects(new Rectangle(goallist[i].x - goallist[i].w / 2, goallist[i].y - goallist[i].h / 2, goallist[i].w, goallist[i].h))) { inGoal = true; } } } if (!inGoal) { goal = goal_reset; if (hud!=null) hud.HideSpinloader(); } else { if (hud != null) hud.Spinloader(goal); if (Global.sound) { switch (goal) { case 90: case 60: case 30: case 1: sound_countdown.resetPosition(); audioplayer2.play(sound_countdown); break; } } goal--; if (goal <= 0) { hud.endLevel(player.moves, stars, coins, totalcoins, coinsCollected[0], coinsCollected[1], coinsCollected[2]); hud.HideSpinloader(); endLevel = true; } } } if (player.moves < 1 && !endLevel && goal==goal_reset && player.body.GetLinearVelocity().Length() < 1) { endLevel = true; hud.createLoseMenu(); } for (var i:int = 0; i < pickuplist.length; i++) { (pickuplist[i] as GeneralObject).update(); if (pickuplist[i].id >= 0 && pickuplist[i].id < 12) { if (!player.drag && (new Rectangle(player.x - player.w / 2, player.y - player.h / 2, player.w, player.h)).intersects(new Rectangle(pickuplist[i].x - pickuplist[i].w / 2, pickuplist[i].y - pickuplist[i].h / 2, pickuplist[i].w, pickuplist[i].h))) { removeCoin(i); pickuplist.splice(i, 1); i--; } } } for (var i:int = 0; i < animationlist.length; i++) { animationlist[i].update(); if (animationlist[i].life <= 0) { if (animationlist[i].model!=null) { animationlist[i].model.rotationX = 0; animationlist[i].model.rotationZ = 0; animationlist[i].model.visible = false; } animationlist[i].model = null; animationlist.splice(i, 1); i--; //trace(""yes""); } } globalMouseX = mouseX; globalMouseY = mouseY; if (keySpace) { mouseAccelY = lerp(mouseAccelY, (mouseY - 240) * 4, 0.2); mouseAccelX = lerp(mouseAccelX, (mouseX - 320) * 4, 0.2); } else { mouseAccelX = lerp(mouseAccelX, 0, 0.4); mouseAccelY = lerp(mouseAccelY, 0, 0.4); } _mug.x = player.x; _mug.z = player.y; _mug.rotationY = player.rotation + 180; if (cameraDisplacementMag > 0) { _view.camera.z = player.y -300+ cameraDisplacementMag * cameraDirection;// - mouseAccelY; _view.camera.x = player.x + cameraDisplacementMag * cameraDirection;// + mouseAccelX; } else { _view.camera.z = player.y-360- mouseAccelY; _view.camera.x = player.x + mouseAccelX; } manageHud(); } private function manageHud():void { if (hud == null) { if (StarlingForeground.hud != null) hud = StarlingForeground.hud; else return; } if (!hud.added) return; if (setuphud) { for (var index:int = 0; index < pickuplist.length; index++) { hud.add_coin(pickuplist[index].x, pickuplist[index].y, pickuplist[index].id); } hud.finalize_coins(); hud.setCoins(totalcoins); updateHudBlocks(); hud.update_player(player.x, player.y); hud.update_stats(player.moves); setuphud = false; } } private function removeCoin(index:int):void { if (hud != null) { if (pickuplist[index].id == 3) { hud.getStar(); stars++; } else { switch (pickuplist[index].id) { case 0: hud.getCoin(25); break; case 1: hud.getCoin(10); break; case 2: hud.getCoin(1); break; } } hud.remove_coin(pickuplist[index].x, pickuplist[index].y); } if (pickuplist[index].id == 3) { if (Global.sound) { sound_star.resetPosition(); var sound_star_resample:IAudioSource = new ResamplingFilter(sound_star, 1.1+(stars-1)/9); audioplayer2.play(sound_star_resample); } } else { switch (pickuplist[index].id) { case 0: coins += 25; coinsCollected[0]++; break; case 1: coins += 10; coinsCollected[1]++; break; case 2: coins++; coinsCollected[2]++; break; } if (Global.sound) { sound_coin.resetPosition(); audioplayer.play(sound_coin); } } animationlist.push(new AnimationContainer((pickuplist[index].id == 3 ? 1 : 0), pickuplist[index].model)); pickuplist[index].model = null; } private function collideWithSolids(collisionBox:Rectangle):Boolean { for (var i:int = 0; i < solidlist.length; i++) if (collisionBox.intersects(solidlist[i])) return true; return false; } private function lerp(val1:int, val2:int, amount:Number):int { return val1 + ((val2 - val1) * amount) } /** * stage listener for resize events */ private function onResize(event:Event = null):void { _view.width = stage.stageWidth; _view.height = stage.stageHeight; } private function mouseUp():void { if (room == 2 && !endLevel) { if (player.drag) { player.drag = false; } } } private function onDeactivate(e:Event):void { if (room == 2 && !endLevel) { Global.pause = true; } } //private function onActivate(e:Event):void { //Global.pause = false; //} private function onMouseUp(e:MouseEvent):void { mouseUp(); } private function onMouseUpOutside(e:MouseEvent):void { mouseUp(); e.target.removeEventListener( MouseEvent.MOUSE_UP, onMouseUpOutside ); } private function onMouseDown(e:MouseEvent):void { if (room == 2 && !endLevel) { if (player.moves>0) { //fireRocket(_turtlegun.rotationY); if (previewCourse) { previewCourse = false; } if (Global.pause) return; if (!player.drag && !keySpace && !(new Rectangle(0, 480-54, 154, 54)).containsPoint(new Point(mouseX,mouseY))) { player.xstart = player.x; player.ystart = player.y; player.mousexstart = mouseX; player.mouseystart = mouseY; player.drag = true; } } else { player.body.SetLinearVelocity(new b2Vec2(0, 0)); } } e.target.stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUpOutside); } private function onKeyboardDown(e:KeyboardEvent):void { switch (e.keyCode) { case 32: keySpace = true; break; } } private function onKeyboardUp(e:KeyboardEvent):void { switch (e.keyCode) { case 32: keySpace = false; break; } } function loadSounds():void { audioplayer = new AudioPlayer(); audioplayer2 = new AudioPlayer(); sound_soda = new SoundSource(new Assets.Sound_Sodagun() as Sound); sound_coin = new SoundSource(new Assets.Sound_Coin() as Sound); sound_thud = new SoundSource(new Assets.Sound_Thud() as Sound); sound_thud2 = new SoundSource(new Assets.Sound_Thud2() as Sound); sound_coindrop = new SoundSource(new Assets.Sound_Coindrop() as Sound); sound_star = new SoundSource(new Assets.Sound_Star() as Sound); sound_countdown = new SoundSource(new Assets.Sound_Countdown() as Sound); sound_button = new SoundSource(new Assets.Sound_Button() as Sound); music = (new Assets.Music() as Sound); musicchannel = music.play(0, 999999); musicchannel.soundTransform = new SoundTransform(0); } static public function resetsave():void { var gameData:XML = ; for (var i:int = 0; i < Global.stars.length; i++) { var recordXML:XML = recordXML.@str = 0; gameData.appendChild(recordXML); } for (var i:int = 0; i < Global.coins.length; i++) { var recordXML:XML = recordXML.@cns = 0; gameData.appendChild(recordXML); } sharedOBJ.data.gameXML = gameData; sharedOBJ.flush(); } static public function save():void { var gameData:XML = ; for (var i:int = 0; i < Global.stars.length; i++) { var recordXML:XML = recordXML.@str = Global.stars[i]; gameData.appendChild(recordXML); } for (var i:int = 0; i < Global.coins.length; i++) { var recordXML:XML = recordXML.@cns = Global.coins[i]; gameData.appendChild(recordXML); } sharedOBJ.data.gameXML = gameData; sharedOBJ.flush(); } static public function load():void { var counter:int = 0; if (sharedOBJ.data.gameXML != undefined) { var xml:XML = sharedOBJ.data.gameXML; for each (var recordXML:XML in xml.str) { if (counter < Global.stars.length) { Global.stars[counter] = recordXML.@str; counter++; } } counter = 0; for each (var recordXML:XML in xml.cns) { if (counter < Global.coins.length) { Global.coins[counter] = recordXML.@cns; counter++; } } } } } } ",12335,False,1988.1922769177943,median "package com.mcleodgaming.as3js.parser { import com.mcleodgaming.as3js.Main; import com.mcleodgaming.as3js.enums.*; import com.mcleodgaming.as3js.types.*; require ""path"" require ""fs"" public class AS3Parser { /** * Keeps track of previous function name to assist extractBlock() debugging * TODO: This could definitely be implemented better */ public static var PREVIOUS_BLOCK:String; //public var index:int; public var stack:Array; public var src:String; public var classPath:String; public var parserOptions:Object; public function AS3Parser(src:String, classPath:String = null):void { //index = 0; stack = []; this.src = src; this.classPath = classPath; parserOptions = { }; parserOptions.safeRequire = false; parserOptions.ignoreFlash = false; } public static function increaseIndent(str:String, indent:String):String { return (indent + str).replace(/\\n/g, ""\\n"" + indent); } public static function parseArguments(str:String):Array { var args:Vector. = new Vector.(); var tmpToken:AS3Token; var tmpArr:Array = AS3Parser.extractBlock(str, 0, '(', ')'); var tmpExtractArr:Array = null; var index:int = tmpArr[1] - 1; //Ending index of parsed block var tmpStr:String = tmpArr[0].trim(); //Parsed block tmpStr = tmpStr.substr(1, tmpStr.length - 2); //Remove outer parentheses tmpArr = null; //Trash this tmpArr = tmpStr.split(','); //Split args by commas //Don't bother if there are no arguments if (tmpArr.length > 0 && tmpArr[0] != '') { //Truncate spaces and assign values to arguments as needed for (var i = 0; i < tmpArr.length; i++) { tmpStr = tmpArr[i].trim(); args.push(new AS3Argument()); if (tmpStr.indexOf('...') === 0) { //This is a ...rest argument, stop here args[args.length-1].name = tmpStr.substr(3); args[args.length-1].isRestParam = true; Main.debug('----->Parsed a ...rest param: ' + args[args.length-1].name); break; } else { //Grab the function name tmpToken = AS3Parser.nextWord(tmpStr, 0, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]); //Parse out the function name args[args.length-1].name = tmpToken.token; //Set the argument name Main.debug('----->Sub-Function argument found: ' + tmpToken.token); //If a colon was next, we'll assume it was typed and grab it if (tmpToken.index < tmpStr.length && tmpStr.charAt(tmpToken.index) == ':') { tmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]); //Parse out the argument type args[args.length-1].type = tmpToken.token; //Set the argument type Main.debug('----->Sub-Function argument typed to: ' + tmpToken.token); } tmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.ASSIGN_START[0], AS3Pattern.ASSIGN_START[1]); if (tmpToken.token == ""="") { //Use all characters after self symbol to set value tmpExtractArr = AS3Parser.extractUpTo(tmpStr, tmpToken.index, /[;\\r\\n]/g); //Store value args[args.length-1].value = tmpExtractArr[0].trim(); //Store value Main.debug('----->Sub-Function argument defaulted to: ' + tmpExtractArr[0].trim()); } } } } return args; } public static function checkForCommentOpen(str:String):String { return (str == ""//"") ? AS3ParseState.COMMENT_INLINE : (str == ""/*"") ? AS3ParseState.COMMENT_MULTILINE : null; } public static function checkForCommentClose(state, str):Boolean { return (state == AS3ParseState.COMMENT_INLINE && (str.charAt(0) == '\\n' || str.charAt(0) == '\\r' || str.charAt(0) == '')) ? true : (state == AS3ParseState.COMMENT_MULTILINE && str == ""*/"") ? true : false; } public static function checkForStringOpen(str:String):String { return (str == '""') ? AS3ParseState.STRING_DOUBLE_QUOTE : (str == ""'"") ? AS3ParseState.STRING_SINGLE_QUOTE : null; } public static function checkForStringClose(state, str):Boolean { return (state == AS3ParseState.STRING_DOUBLE_QUOTE && str == '""') ? true : (state == AS3ParseState.STRING_SINGLE_QUOTE && str == ""'"") ? true : false; } public static function nextWord(src:String, index:int, characters:String, pattern:String):AS3Token { characters = characters || AS3Pattern.IDENTIFIER[0]; pattern = pattern || AS3Pattern.IDENTIFIER[1]; var tokenBuffer:String = null; var extraBuffer:String = ''; //Contains characters that were missed var escapeToggle:Boolean = false; var innerState:String = null; for (; index < src.length; index++) { var c = src.charAt(index); if (c.match(characters)) { tokenBuffer = (tokenBuffer) ? tokenBuffer + c : c; //Create new token buffer if needed, otherwise append } else if (!innerState && AS3Parser.checkForCommentOpen(src.substr(index, 2)) && !tokenBuffer) { tokenBuffer = null; Main.debug(""Entering comment...""); innerState = AS3Parser.checkForCommentOpen(src.substr(index, 2)); extraBuffer += src.substr(index, 2); index += 2; //Skip next index //Loop until we break out of comment for (; index < src.length; index++) { if (AS3Parser.checkForCommentClose(innerState, src.substr(index, 2))) { if (innerState == AS3ParseState.COMMENT_MULTILINE) { extraBuffer += src.substr(index, 2); index++; //Skip next token } else { extraBuffer += src.charAt(index); } innerState = null; //Return to previous state Main.debug(""Exiting comment...""); break; } else { extraBuffer += src.charAt(index); } } } else if (!innerState && AS3Parser.checkForStringOpen(src.charAt(index)) && !tokenBuffer) { tokenBuffer = null; Main.debug(""Entering string...""); innerState = AS3Parser.checkForStringOpen(src.charAt(index)); extraBuffer += src.substr(index, 1); index++; //Skip to next index //Loop until we break out of string for (; index < src.length; index++) { extraBuffer += src.charAt(index); if (!escapeToggle && src.charAt(index) == '\\\\') { escapeToggle = true; continue; } escapeToggle = false; if (AS3Parser.checkForStringClose(innerState, src.charAt(index))) { innerState = null; //Return to previous state Main.debug(""Exiting string...""); break; } } } else if (tokenBuffer && tokenBuffer.match(pattern)) { return new AS3Token(tokenBuffer, index, extraBuffer); //[Token, Index] } else { if (tokenBuffer) { extraBuffer += tokenBuffer + c; } else { extraBuffer += c; } tokenBuffer = null; } } return new AS3Token(tokenBuffer || null, index, extraBuffer); //[Token, Index] } public static function extractBlock(text:String, start:int = 0, opening:String = ""{"", closing:String = ""}""):Array { var buffer:String = """"; var i:int = start; var count:int = 0; var started:Boolean = false; var insideString:String = null; var insideComment:String = null; var escapingChar:Boolean = false; while (!(count == 0 && started) && i < text.length) { if (insideComment) { //Inside of a comment, wait until we get out if (insideComment == '//' && (text.charAt(i) == '\\n' || text.charAt(i) == '\\r')) { insideComment = null; //End inline comment Main.debug(""Exited comment""); } else if (insideComment == '/*' && text.charAt(i) == '*' && i + 1 < text.length && text.charAt(i + 1) == '/') { insideComment = null; //End multiline comment Main.debug(""Exited comment""); } } else if (insideString) { //Inside of a string, wait until we get out if (!escapingChar && text.charAt(i) == ""\\\\"") { escapingChar = true; //Start escape sequence } else if (!escapingChar && text.charAt(i) == insideString) { insideString = null; //Found closing quote } else { escapingChar = false; //Forget escape sequence } } else if (text.charAt(i) == opening) { started = true; count++; //Found opening } else if (text.charAt(i) == closing) { count--; //Found closing } else if ((text.charAt(i) == '\\""' || text.charAt(i) == '\\'')) { insideString = text.charAt(i); //Now inside of a string } else if (text.charAt(i) == '/' && i + 1 < text.length && text.charAt(i + 1) == '/') { Main.debug(""Entering comment... "" + ""(//)""); insideComment = '//'; } else if (text.charAt(i) == '/' && i + 1 < text.length && text.charAt(i + 1) == '*') { Main.debug(""Entering comment..."" + ""(/*)""); insideComment = '/*'; } if (started) { buffer += text.charAt(i); } i++; } if (!started) { throw new Error(""Error, no starting '"" + opening + ""' found for method body while parsing "" + AS3Parser.PREVIOUS_BLOCK); } else if (count > 0) { throw new Error(""Error, no closing '"" + closing + ""' found for method body while parsing "" + AS3Parser.PREVIOUS_BLOCK); } else if (count < 0) { throw new Error(""Error, malformed enclosing '"" + opening + closing + "" body while parsing "" + AS3Parser.PREVIOUS_BLOCK); } return [buffer, i]; } public static function extractUpTo(text:String, start:int, target:String):Array { var buffer:String = """"; var i:int = start; var insideString:String = null; var insideComment:String = null; var escapingChar:Boolean = false; var pattern:String = new RegExp(target); while (i < text.length) { if (insideComment) { //Inside of a comment, wait until we get out if (insideComment == '//' && (text.charAt(i) == '\\n' || text.charAt(i) == '\\r')) { insideComment = null; //End inline comment Main.debug(""Exited comment""); } else if (insideComment == '/*' && text.charAt(i) == '*' && i + 1 < text.length && text.charAt(i + 1) == '/') { insideComment = null; //End multiline comment Main.debug(""Exited comment""); } } else if (insideString) { //Inside of a string, wait until we get out if (!escapingChar && text.charAt(i) == ""\\\\"") { escapingChar = true; //Start escape sequence } else if (!escapingChar && text.charAt(i) == insideString) { insideString = null; //Found closing quote } else { escapingChar = false; //Forget escape sequence } } else if ((text.charAt(i) == '\\""' || text.charAt(i) == '\\'')) { insideString = text.charAt(i); //Now inside of a string } else if (text.charAt(i) == '/' && i + 1 < text.length && text.charAt(i + 1) == '/') { Main.debug(""Entering comment... "" + ""(//)""); insideComment = '//'; } else if (text.charAt(i) == '/' && i + 1 < text.length && text.charAt(i + 1) == '*') { Main.debug(""Entering comment..."" + ""(/*)""); insideComment = '/*'; } else if (text.charAt(i).match(pattern)) { break; //Done } buffer += text.charAt(i); i++; } return [buffer, i]; } public static function fixClassPath(clsPath:String):String { // Class paths at the root level might accidentally be prepended with a ""."" return clsPath.replace(/^\\./g, """"); } public function getState():String { return (this.stack.length > 0) ? this.stack[this.stack.length - 1] : null; } private function parseHelper(cls:AS3Class, src:String):void { var i:*; var j:*; var c:String; var currToken:AS3Token = null; var tmpToken:AS3Token = null; var tmpStr:String = null; var tmpArr:Array = null; var currMember:AS3Member = null; var index:int; for (index = 0; index < src.length; index++) { c = src.charAt(index); if (getState() == AS3ParseState.START) { //String together letters only until we reach a non-letter currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]); index = currToken.index - 1; //Update to the new position if (currToken.token == 'package') { stack.push(AS3ParseState.PACKAGE_NAME); } } else if (getState() == AS3ParseState.PACKAGE_NAME) { currToken = AS3Parser.nextWord(src, index, AS3Pattern.OBJECT[0], AS3Pattern.OBJECT[1]); //Package name tmpToken = AS3Parser.nextWord(src, index, AS3Pattern.CURLY_BRACE[0], AS3Pattern.CURLY_BRACE[1]); //Upcoming curly brace index = currToken.index - 1; if (!currToken.token || !tmpToken.token) { throw new Error(""Error parsing package name.""); } else { if (tmpToken.index < currToken.index) { cls.packageName = ''; //Curly brace came before next token index = tmpToken.index; } else { cls.packageName = currToken.token; //Just grab the package name } Main.debug('Found package: ' + cls.packageName); cls.importWildcards.push(AS3Parser.fixClassPath(cls.packageName + '.*')); //Add wild card for its own folder stack.push(AS3ParseState.PACKAGE); Main.debug('Attempting to parse package...'); } } else if (getState() == AS3ParseState.PACKAGE) { currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]); index = currToken.index - 1; if (currToken.token == 'class' || currToken.token == 'interface') { if(currToken.token == 'interface') cls.isInterface = true; stack.push(AS3ParseState.CLASS_NAME); Main.debug('Found class keyword...'); } else if (currToken.token == 'import') { stack.push(AS3ParseState.IMPORT_PACKAGE); Main.debug('Found import keyword...'); } else if (currToken.token == 'require') { stack.push(AS3ParseState.REQUIRE_MODULE); Main.debug('Found require keyword...'); } } else if (getState() == AS3ParseState.CLASS_NAME) { currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]); tmpToken = AS3Parser.nextWord(src, index, AS3Pattern.CURLY_BRACE[0], AS3Pattern.CURLY_BRACE[1]); index = currToken.index; if (!currToken.token || !tmpToken.token) { throw new Error(""Error parsing class name.""); } else if (tmpToken.index < currToken.index) { throw new Error(""Error, no class name found before curly brace.""); } else { //Set the class name cls.className = currToken.token; // Update fully qualified class path if needed classPath = classPath || AS3Parser.fixClassPath(cls.packageName + '.' + cls.className); //Remove extra ""."" for top level packages cls.classMap[cls.className] = cls; //Register self into the import map (used for static detection) //Now we will check for parent class and any interfaces currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]); if (currToken.token == 'extends' && currToken.index < tmpToken.index) { index = currToken.index; currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]); index = currToken.index; //The token following 'extends' must be the parent class cls.parent = currToken.token; //Prep the next token currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]); Main.debug(""Found parent: "" + cls.parent); } if (currToken.token == 'implements' && currToken.index < tmpToken.index) { index = currToken.index; currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]); index = currToken.index; //The token following 'implements' must be an interface cls.interfaces.push(currToken.token); Main.debug(""Found interface: "" + currToken.token); currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]); //While we are at a token before the next curly brace while (currToken.index < tmpToken.index && currToken.index < src.length) { //Consider self token another interface being implemented index = currToken.index; Main.debug(""Found interface: "" + currToken.token); cls.interfaces.push(currToken.token); currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]); index = currToken.index; } } Main.debug('Parsed class name: ' + cls.className); //Now parsing inside of the class stack.push(AS3ParseState.CLASS); Main.debug('Attempting to parse class...'); //Extract out the next method block AS3Parser.PREVIOUS_BLOCK = cls.className + "":Class""; tmpStr = AS3Parser.extractBlock(src, index)[0]; index += tmpStr.length - 1; //Recursively call parseHelper again under this new state (Once returned, package will be exited) parseHelper(cls, tmpStr); } } else if (getState() == AS3ParseState.CLASS) { currMember = currMember || new AS3Member(); //Declare a new member to work with if it doesn't exist yet currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]); index = currToken.index - 1; if (currToken.token == AS3Encapsulation.PUBLIC || currToken.token == AS3Encapsulation.PRIVATE || currToken.token == AS3Encapsulation.PROTECTED) { currMember.encapsulation = currToken.token; Main.debug('->Member encapsulation set to ' + currMember.encapsulation); } else if (currToken.token == 'static') { currMember.isStatic = true; Main.debug('-->Static flag set'); } else if (currToken.token == AS3MemberType.VAR || currToken.token == AS3MemberType.CONST) { Main.debug('--->Member type ""variable"" set.'); currMember = currMember.createVariable(); //Transform the member into a variable stack.push(AS3ParseState.MEMBER_VARIABLE); } else if (currToken.token == AS3MemberType.FUNCTION) { currToken = AS3Parser.nextWord(src, index + 1, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]); //Check for getter/setter if ((currToken.token == 'get' || currToken.token == 'set') && src[index + 1 + currToken.token.length + 1] != '(') { Main.debug('--->Member sub-type ""' + currToken.token + '"" set.'); currMember.subType = currToken.token; index = currToken.index - 1; } currMember = currMember.createFunction(); //Transform the member into a function stack.push(AS3ParseState.MEMBER_FUNCTION); Main.debug('---->Member type ""function"" set.'); } } else if (getState() == AS3ParseState.MEMBER_VARIABLE) { currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]); currMember.name = currToken.token; //Set the member name Main.debug('---->Variable name declared: ' + currToken.token); index = currToken.index; if (src.charAt(index) == "":"") { currToken = AS3Parser.nextWord(src, index, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]); index = currToken.index; currMember.type = currToken.token;//Set the value type name Main.debug('---->Variable type for ' + currMember.name + ' declared as: ' + currToken.token); } currToken = AS3Parser.nextWord(src, index, AS3Pattern.ASSIGN_START[0], AS3Pattern.ASSIGN_START[1]); if (currToken.token == ""="") { //Use all characters after self symbol to set value index = currToken.index; tmpArr = AS3Parser.extractUpTo(src, index, /[;\\r\\n]/g); //Store value currMember.value = tmpArr[0].trim(); index = tmpArr[1]; cls.membersWithAssignments.push(currMember); } //Store and delete current member and exit if (currMember.isStatic) { cls.staticMembers.push(currMember); } else { cls.members.push(currMember); } cls.registerField(currMember.name, currMember); currMember = null; stack.pop(); } else if (getState() == AS3ParseState.MEMBER_FUNCTION) { //Parse the arguments currToken = AS3Parser.nextWord(src, index, AS3Pattern.IDENTIFIER[0], AS3Pattern.IDENTIFIER[1]); index = currToken.index; currMember.name = currToken.token; //Set the member name Main.debug('****>Function name declared: ' + currToken.token); AS3Parser.PREVIOUS_BLOCK = currMember.name + "":Function""; tmpArr = AS3Parser.extractBlock(src, index, '(', ')'); index = tmpArr[1] - 1; //Ending index of parsed block tmpStr = tmpArr[0].trim(); //Parsed block tmpStr = tmpStr.substr(1, tmpStr.length - 2); //Remove outer parentheses tmpArr = null; //Trash this tmpArr = tmpStr.split(','); //Split args by commas //Don't bother if there are no arguments if (tmpArr.length > 0 && tmpArr[0] != '') { //Truncate spaces and assign values to arguments as needed for (i = 0; i < tmpArr.length; i++) { tmpStr = tmpArr[i]; //Grab the function name tmpToken = AS3Parser.nextWord(tmpStr, 0, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]); //Parse out the function name currMember.argList.push(new AS3Argument()); if (tmpStr.indexOf('...') === 0) { //This is a ...rest argument, stop here currMember.argList[currMember.argList.length-1].name = tmpStr.substr(3); currMember.argList[currMember.argList.length-1].isRestParam = true; Main.debug('----->Parsed a ...rest param: ' + currMember.argList[currMember.argList.length-1].name); break; } else { currMember.argList[currMember.argList.length-1].name = tmpToken.token; //Set the argument name Main.debug('----->Function argument found: ' + tmpToken.token); //If a colon was next, we'll assume it was typed and grab it if (tmpToken.index < tmpStr.length && tmpStr.charAt(tmpToken.index) == ':') { tmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]); //Parse out the argument type currMember.argList[currMember.argList.length-1].type = tmpToken.token; //Set the argument type Main.debug('----->Function argument typed to: ' + tmpToken.token); } tmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.ASSIGN_START[0], AS3Pattern.ASSIGN_START[1]); if (tmpToken.token == ""="") { //Use all characters after self symbol to set value tmpToken = AS3Parser.nextWord(tmpStr, tmpToken.index, AS3Pattern.ASSIGN_UPTO[0], AS3Pattern.ASSIGN_UPTO[1]); if (!tmpToken) { throw new Error(""Error during variable assignment in arg"" + currMember.argList[currMember.argList.length - 1].name); } //Store value currMember.argList[currMember.argList.length-1].value = tmpToken.token.trim(); Main.debug('----->Function argument defaulted to: ' + tmpToken.token.trim()); } } } } Main.debug('------>Completed paring args: ', currMember.argList); //Type the function if needed if (src.charAt(index + 1) == "":"") { tmpToken = AS3Parser.nextWord(src, index + 1, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]); //Parse out the function type if needed index = tmpToken.index; currMember.type = tmpToken.token; Main.debug('------>Typed the function to: ', currMember.type); } if (cls.isInterface) { //Store and delete current member and exit currMember.value = '{}'; if (currMember.subType == 'get') { (currMember.isStatic) ? cls.staticGetters.push(currMember) : cls.getters.push(currMember); } else if (currMember.subType == 'set') { (currMember.isStatic) ? cls.staticSetters.push(currMember) : cls.setters.push(currMember); } else if (currMember.isStatic) { cls.staticMembers.push(currMember); } else { cls.members.push(currMember); } cls.registerField(currMember.name, currMember); //Done parsing function currMember = null; stack.pop(); } else { //Save the function body AS3Parser.PREVIOUS_BLOCK = currMember.name + "":Function""; tmpArr = AS3Parser.extractBlock(src, index); index = tmpArr[1]; currMember.value = tmpArr[0].trim(); //Store and delete current member and exit if (currMember.subType == 'get') { (currMember.isStatic) ? cls.staticGetters.push(currMember) : cls.getters.push(currMember); } else if (currMember.subType == 'set') { (currMember.isStatic) ? cls.staticSetters.push(currMember) : cls.setters.push(currMember); } else if (currMember.isStatic) { cls.staticMembers.push(currMember); } else { cls.members.push(currMember); } cls.registerField(currMember.name, currMember); currMember = null; stack.pop(); } } else if (getState() == AS3ParseState.LOCAL_VARIABLE) { } else if (getState() == AS3ParseState.LOCAL_FUNCTION) { } else if (getState() == AS3ParseState.IMPORT_PACKAGE) { //The current token is a class import currToken = AS3Parser.nextWord(src, index, AS3Pattern.IMPORT[0], AS3Pattern.IMPORT[1]); index = currToken.index - 1; if (!currToken.token) { throw new Error(""Error parsing import.""); } else { Main.debug(""Parsed import name: "" + currToken.token); if (currToken.token.indexOf(""*"") >= 0) { cls.importWildcards.push(currToken.token); //To be resolved later } else { cls.imports.push(currToken.token); //No need to resolve } stack.push(AS3ParseState.PACKAGE); } } else if (getState() == AS3ParseState.REQUIRE_MODULE) { //The current token is a module requirement currToken = AS3Parser.nextWord(src, index, AS3Pattern.REQUIRE[0], AS3Pattern.REQUIRE[1]); index = currToken.index - 1; if(!currToken.token) throw new Error(""Error parsing require.""); else { Main.debug(""Parsed require name: "" + currToken.token); cls.requires.push(currToken.token.trim()); stack.push(AS3ParseState.PACKAGE); } } } } public function parse(options:Object = null):AS3Class { options = options || { }; if (typeof options.safeRequire !== 'undefined') { parserOptions.safeRequire = options.safeRequire; } if (typeof options.ignoreFlash !== 'undefined') { parserOptions.ignoreFlash = options.ignoreFlash; } var classDefinition:AS3Class = new AS3Class(parserOptions); stack.splice(0, stack.length); stack.push(AS3ParseState.START); parseHelper(classDefinition, src); if (!classDefinition.className) { throw new Error(""Error, no class provided for package: "" + classPath); } return classDefinition; } public static function checkArguments(fn:AS3Function):String { if (fn.argList.length <= 0) { return fn.value; } var start:int = fn.value.indexOf('{'); var args:String = """"; for (var i:int = 0; i < fn.argList.length; i++) { //We will inject arguments into the top of the method definition if (fn.argList[i].isRestParam) { args += ""\\n\\t\\t\\tvar "" + fn.argList[i].name + "" = Array.prototype.slice.call(arguments).splice("" + i + "");""; } else if (fn.argList[i].value) { args += ""\\n\\t\\t\\t"" + fn.argList[i].name + "" = AS3JS.Utils.getDefaultValue("" + fn.argList[i].name + "", "" + fn.argList[i].value + "");""; } } return fn.value.substr(0, start + 1) + args + fn.value.substr(start + 1); } public static function injectInstantiations(cls:AS3Class, fn:AS3Function):String { var start:int = fn.value.indexOf('{'); var text:String = """"; for (var i = 0; i < cls.members.length; i++) { //We will inject instantiated vars into the top of the method definition if (cls.members[i] instanceof AS3Variable && AS3Class.nativeTypes.indexOf(cls.members[i].type) < 0) { text += ""\\n\\t\\t\\tthis."" + cls.members[i].name + "" = "" + cls.members[i].value + "";""; } } return fn.value.substr(0, start + 1) + text + fn.value.substr(start + 1); } public static function injectInit(cls:AS3Class, fn:AS3Function):String { var start:int = fn.value.indexOf('{'); var text:String = ""\\n\\t\\t\\tthis.$init();""; return fn.value.substr(0, start + 1) + text + fn.value.substr(start + 1); } public static function checkStack(stack:Array, name:String):void { if (!name) { return null; } for (var i = stack.length - 1; i >= 0; i--) { if (stack[i].name == name) { return stack[i]; } } return null; } public static function lookAhead(str:String, index:int):Object { //Look ahead in the function for assignments var originalIndex:int = index; var startIndex:int = -1; var endIndex:int = -1; var semicolonIndex:int = -1; var token:String = """"; var extracted:String = """"; //Not a setter if there is a dot operator immediately after if (str.charAt(index) == '.') { return { token: null, extracted: '', startIndex: startIndex, endIndex: endIndex }; } for (; index < str.length; index++) { if(str.charAt(index).match(/[+-\\/=*]/g)) { //Append to the assignment instruction token += str.charAt(index); startIndex = index; } else if (startIndex < 0 && str.charAt(index).match(/[\\t\\s]/g)) //Skip these characters { continue; } else { break; //Exits when token has already been started and no more regexes pass } } //Only allow these patterns if (!(token == ""="" || token == ""++"" || token == ""--"" || token == ""+="" || token == ""-="" || token == ""*="" || token == ""/="")) { token = null; } if (token) { //Pick whatever is closer, new line or semicolon endIndex = str.indexOf('\\n', startIndex); if (endIndex < 0) { endIndex = str.length - 1; } //Windows fix if (str.charAt(endIndex - 1) == '\\r') { endIndex--; } //We want to place closing parens before semicolon if it exists semicolonIndex = str.indexOf("";"", startIndex); if (semicolonIndex < endIndex) { endIndex = semicolonIndex; } extracted = str.substring(startIndex + token.length, endIndex); } return { token: token, extracted: extracted, startIndex: startIndex, endIndex: endIndex }; } public static function parseFunc(cls:AS3Class, fnText:String, stack:Array, statFlag:Boolean = false):Array { var i:int; var j:int; var index:int = 0; var result:String = ''; var tmpStr:String = ''; var tmpArgs:Vector.; var tmpMember:AS3Member; var tmpClass:AS3Class; var tmpField:AS3Member; var prevToken:AS3Token; var currToken:AS3Token; var tmpParse:String; var tmpStatic:Boolean = false; var tmpPeek:String; var objBuffer = ''; //Tracks the current object that is being ""pathed"" (e.g. ""object.field1"" or ""object.field1[index + 1]"", etc) var justCreatedVar:Boolean = false; //Keeps track if we just started a var statement (to help test if we're setting a type)) for (index = 0; index < fnText.length; index++) { objBuffer = ''; prevToken = currToken; currToken = AS3Parser.nextWord(fnText, index, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]); result += currToken.extra; //<-Puts all other non-identifier characters into the buffer first tmpMember = AS3Parser.checkStack(stack, currToken.token); //<-Check the stack for a member with this identifier already index = currToken.index; if (currToken.token) { if (currToken.token == 'function') { var t1 = AS3Parser.nextWord(fnText, index, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]); var t2 = fnText.indexOf('(', index); //If the parenthesis si less than the last index of the next parsed variable name result += (t2 < t1.index) ? 'function' : 'function ' + t1.token; tmpParse = AS3Parser.extractBlock(fnText, index, '(', ')'); //Parse out argument block index = tmpParse[1]; //Update index tmpArgs = AS3Parser.parseArguments(tmpParse[0]); //Extract arg types //Join the args together without types result += '(' + (function(args) { var arr = []; for (var i = 0; i < args.length; i++) { if (args[i] === '...rest') { break; } arr.push(args[i].name); } var str = arr.join(', '); return str; })(tmpArgs) + ')'; tmpParse = AS3Parser.extractBlock(fnText, index, '{', '}'); //Extract function block index = tmpParse[1] - 1; //Update index tmpParse = AS3Parser.parseFunc(cls, tmpParse[0], stack.concat(tmpArgs), statFlag); //Recurse into function result += ' ' + tmpParse[0]; } else { if (currToken.token == 'this') { //No need to perform any extra checks on the subsequent token tmpStatic = false; tmpClass = cls; objBuffer += currToken.token; result += currToken.token; } else { if (cls.classMap[currToken.token] && cls.parentDefinition !== cls.classMap[currToken.token] && !(justCreatedVar && currToken.extra.match(/:\\s*/g))) { // If this is a token that matches a class from a potential import statement, store it in the filtered classMap cls.classMapFiltered[currToken.token] = cls.classMap[currToken.token]; } tmpStatic = (cls.className == currToken.token || cls.retrieveField(currToken.token, true) !== null); //Find field in class, then make sure we didn't already have a local member defined with this name, and skip next block if static since the definition is the class itself //Note: tmpMember needs to be checked, if something is in there it means we have a variable with the same name in local scope if (cls.retrieveField(currToken.token, tmpStatic) && cls.className != currToken.token && !tmpMember && !(prevToken && prevToken.token === ""var"")) { tmpMember = cls.retrieveField(currToken.token, tmpStatic); //<-Reconciles the type of the current variable if (tmpMember && (tmpMember.subType == 'get' || tmpMember.subType == 'set')) { tmpPeek = AS3Parser.lookAhead(fnText, index); if (tmpPeek.token) { //Handle differently if we are assigning a setter //Prepend the correct term if (tmpStatic) { objBuffer += (cls.retrieveField(currToken.token, tmpStatic)) ? cls.className + '.' : currToken.token + '.'; result += (cls.retrieveField(currToken.token, tmpStatic)) ? cls.className + '.' : currToken.token + '.'; } else { objBuffer += 'this.'; result += 'this.'; } objBuffer += 'get_' + currToken.token + '()'; result += 'set_' + currToken.token + '('; index = tmpPeek.endIndex; if (tmpPeek.token == '++') { result += objBuffer + ' + 1'; } else if (tmpPeek.token == '--') { result += objBuffer + ' - 1'; } else { tmpParse = AS3Parser.parseFunc(cls, tmpPeek.extracted, stack); //Recurse into the assignment to parse vars if (tmpPeek.token == '=') { result += tmpParse[0].trim(); } else { result += objBuffer + ' ' + tmpPeek.token.charAt(0) + ' (' + tmpParse[0] + ')'; } } result += ')'; } else { //Getters are easy if (tmpStatic) { objBuffer += (cls.retrieveField(currToken.token, true)) ? cls.className + '.get_' + currToken.token + '()' : 'this.get_' + currToken.token + '()'; result += (cls.retrieveField(currToken.token, true)) ? cls.className + '.get_' + currToken.token + '()' : 'this.get_' + currToken.token + '()'; } else { objBuffer += 'this.get_' + currToken.token + '()'; result += 'this.get_' + currToken.token + '()'; } } } else { if (tmpStatic) { objBuffer += (cls.className == currToken.token) ? currToken.token : cls.className + '.' + currToken.token; result += (cls.className == currToken.token) ? currToken.token : cls.className + '.' + currToken.token; } else { objBuffer += (cls.retrieveField(currToken.token, false) && !statFlag && !(prevToken && prevToken.token === 'new' && cls.retrieveField(currToken.token, false).type !== ""Class"")) ? 'this.' + currToken.token : currToken.token; result += (cls.retrieveField(currToken.token, false) && !statFlag && !(prevToken && prevToken.token === 'new' && cls.retrieveField(currToken.token, false).type !== ""Class"")) ? 'this.' + currToken.token : currToken.token; } } } else { //Likely a local variable, argument, or static reference if (tmpStatic) { objBuffer += currToken.token; result += currToken.token; } else { objBuffer += (cls.retrieveField(currToken.token, false) && !tmpMember && !(prevToken && prevToken.token === ""var"")) ? 'this.' + currToken.token : currToken.token; result += (cls.retrieveField(currToken.token, false) && !tmpMember && !(prevToken && prevToken.token === ""var"")) ? 'this.' + currToken.token : currToken.token; } } if (tmpStatic) { //Just use the class itself, we will reference fields from it. If parser injected the static prefix manually, we'll try to determome the type of var instead tmpClass = (cls.className == currToken.token) ? cls : (tmpMember) ? cls.classMap[tmpMember.type] || null : null; } else { //Use the member's type to determine the class it's mapped to tmpClass = (tmpMember && tmpMember.type && tmpMember.type != '*') ? cls.classMap[tmpMember.type] : null; //If no mapping was found, this may be a static reference if (!tmpClass && cls.classMap[currToken.token]) { tmpClass = cls.classMap[currToken.token]; tmpStatic = true; } } //If tmpClass is null, it's possible we were trying to retrieve a Vector type. Let's fix this: if (!tmpClass && tmpMember && tmpMember.type && tmpMember.type.replace(/Vector\\.<(.*?)>/g, ""$1"") != tmpMember.type) { //Extract Vector type if necessary by testing regex tmpClass = cls.classMap[tmpMember.type.replace(/Vector\\.<(.*?)>/g, ""$1"")] || null; } } //Note: At this point, tmpMember is no longer used, it was only needed to remember the type of the first token. objBuffer will be building out the token //If this had a variable declaration before it, we will add it to the local var stack and move on to the next token if (prevToken && prevToken.token === ""var"") { justCreatedVar = true; if (cls.retrieveField(currToken.token, tmpStatic)) { //Appends current character index to the result, add dummy var to stack, and move on result += fnText.charAt(index); var localVar:AS3Member = new AS3Member(); localVar.name = currToken.token; stack.push(localVar); //<-Ensures we don't add ""this."" or anything in front of this variable anymore continue; } } else { justCreatedVar = false; } //We have parsed the current token, and the index sits at the next level down in the object for (; index < fnText.length; index++) { //Loop until we stop parsing a variable declaration if (fnText.charAt(index) == '.') { var parsingVector = (prevToken && prevToken.token === 'new' && currToken.token === 'Vector'); prevToken = currToken; if (parsingVector) { //We need to allow asterix currToken = AS3Parser.nextWord(fnText, index, AS3Pattern.VARIABLE_TYPE[0], AS3Pattern.VARIABLE_TYPE[1]); } else { currToken = AS3Parser.nextWord(fnText, index, AS3Pattern.VARIABLE[0], AS3Pattern.VARIABLE[1]); } result += currToken.extra; //<-Puts all other non-identifier characters into the buffer first index = currToken.index; if (tmpClass) { //This means we are coming from a typed variable tmpField = tmpClass.retrieveField(currToken.token, tmpStatic); if (tmpField) { //console.log(""parsing: "" + tmpField.name + "":"" + tmpField.type) //We found a field that matched this value within the class if (tmpField instanceof AS3Function) { if (tmpField.subType == 'get' || tmpField.subType == 'set') { tmpPeek = AS3Parser.lookAhead(fnText, index); if (tmpPeek.token) { //Handle differently if we are assigning a setter objBuffer += '.get_' + currToken.token + '()'; result += 'set_' + currToken.token + '('; index = tmpPeek.endIndex; if (tmpPeek.token == '++') { result += objBuffer + ' + 1'; } else if (tmpPeek.token == '--') { result += objBuffer + ' - 1'; } else { tmpParse = AS3Parser.parseFunc(cls, tmpPeek.extracted, stack); //Recurse into the assignment to parse vars if (tmpPeek.token == '=') { result += tmpParse[0].trim(); } else { result += objBuffer + ' ' + tmpPeek.token.charAt(0) + ' (' + tmpParse[0] + ')'; } } result += ')'; } else { objBuffer += '.get_' + currToken.token + '()'; result += 'get_' + currToken.token + ""()""; } //console.log(""set get flag: "" + currToken.token); } else { objBuffer += '.' + currToken.token; result += currToken.token; } } else { objBuffer += '.' + currToken.token; result += currToken.token; } } else { objBuffer += '.' + currToken.token; result += currToken.token; //console.log(""appened typed: "" + currToken.token); } //Update the type if this is not a static prop if (tmpClass && tmpField && tmpField.type && tmpField.type != '*') { //Extract Vector type if necessary by testing regex tmpClass = (tmpField.type.replace(/Vector\\.<(.*?)>/g, ""$1"") != tmpField.type) ? tmpClass.classMap[tmpField.type.replace(/Vector\\.<(.*?)>/g, ""$1"")] || null : tmpClass.classMap[tmpField.type] || null; } else { tmpClass = null; } } else { //console.log(""appened untyped: "" + currToken.token); objBuffer += '.' + currToken.token; result += currToken.token; } } else if (fnText.charAt(index) == '[') { //We now have to recursively parse the inside of this open bracket tmpParse = AS3Parser.extractBlock(fnText, index, '[', ']'); index = tmpParse[1]; tmpParse = AS3Parser.parseFunc(cls, tmpParse[0], stack); //Recurse into the portion that was extracted //console.log(""recursed into: "" + tmpParse[0]); objBuffer += tmpParse[0]; //Append this text to the object buffer string so we can remember the variable we have accessed result += tmpParse[0]; } tmpStatic = false; //Static can no longer be possible after the second field if (!fnText.charAt(index).match(/[.\\[]/g)) { objBuffer = ''; //Clear out the current object buffer index--; break; } index--; } } } else { index = currToken.index - 1; } } return [result, index]; } public static function cleanup(text:String):String { var i:int; var type:String; var params:Array; var val:String; var matches:Array = text.match(AS3Pattern.VECTOR[0]); //For each Vector.<>() found in the text for (i in matches) { //Strip the type and provided params type = matches[i].replace(AS3Pattern.VECTOR[0], '$1').trim(); params = matches[i].replace(AS3Pattern.VECTOR[0], '$2').split(','); //Set the default based on var type if (type == 'int' || type == 'uint' || type == 'Number') { val = ""0""; } else if (type == 'Boolean') { val = ""false""; } else { val = ""null""; } //Replace accordingly if (params.length > 0 && params[0].trim() != '') { text = text.replace(AS3Pattern.VECTOR[1], ""AS3JS.Utils.createArray("" + params[0] + "", "" + val + "")""); } else { text = text.replace(AS3Pattern.VECTOR[1], ""[]""); } } matches = text.match(AS3Pattern.ARRAY[0]); //For each Array() found in the text for (i in matches) { //Strip the provided params params = matches[i].replace(AS3Pattern.ARRAY[0], '$1').trim(); //Replace accordingly if (params.length > 0 && params[0].trim() != '') { text = text.replace(AS3Pattern.ARRAY[1], ""AS3JS.Utils.createArray("" + params[0] + "", null)""); } else { text = text.replace(AS3Pattern.ARRAY[1], ""[]""); } } matches = text.match(AS3Pattern.DICTIONARY[0]); //For each instantiated Dictionary found in the text for (i in matches) { // Replace with empty object text = text.replace(AS3Pattern.DICTIONARY[0], ""{}""); } //Now cleanup variable types text = text.replace(/([^0-9a-zA-Z_$.])(?:var|const)(\\s*[a-zA-Z_$*][0-9a-zA-Z_$.<>]*)\\s*:\\s*([a-zA-Z_$*][0-9a-zA-Z_$.<>]*)/g, ""$1var$2""); return text; } } }",12540,False,2386.1784480208403,median "/** * VERSION: 1.66 * DATE: 2011-01-25 * AS3 (AS2 version is also available) * UPDATES AND DOCS AT: http://www.greensock.com/timelinemax/ **/ package com.greensock { import com.greensock.core.*; import com.greensock.events.TweenEvent; import flash.events.*; /** * TimelineMax extends TimelineLite, offering exactly the same functionality plus useful * (but non-essential) features like AS3 event dispatching, repeat, repeatDelay, yoyo, * currentLabel, addCallback(), removeCallback(), tweenTo(), tweenFromTo(), getLabelAfter(), getLabelBefore(), * and getActive() (and probably more in the future). It is the ultimate sequencing tool. * Think of a TimelineMax instance like a virtual MovieClip timeline or a container where * you place tweens (or other timelines) over the course of time. You can: * *
    *
  • build sequences easily by adding tweens with the append(), prepend(), insert(), appendMultiple(), * prependMultiple(), and insertMultiple() methods. Tweens can overlap as much as you want and you have * complete control over where they get placed on the timeline.
  • * *
  • add labels, play(), stop(), gotoAndPlay(), gotoAndStop(), restart(), tweenTo() and even reverse()!
  • * *
  • nest timelines within timelines as deeply as you want.
  • * *
  • set the progress of the timeline using its currentProgress property. For example, to skip to * the halfway point, set myTimeline.currentProgress = 0.5.
  • * *
  • tween the currentTime, totalTime, currentProgress, or totalProgress * property to fastforward/rewind the timeline. You could * even attach a slider to one of these properties to give the user the ability to drag * forwards/backwards through the whole timeline.
  • * *
  • add onStart, onUpdate, onComplete, onReverseComplete, and/or onRepeat callbacks using the * constructor's vars object.
  • * *
  • speed up or slow down the entire timeline with its timeScale property. You can even tween * this property to gradually speed up or slow down the timeline.
  • * *
  • use the insertMultiple(), appendMultiple(), or prependMultiple() methods to create * complex sequences including various alignment modes and staggering capabilities. * Works great in conjunction with TweenMax.allTo() too.
  • * *
  • base the timing on frames instead of seconds if you prefer. Please note, however, that * the timeline's timing mode dictates its childrens' timing mode as well.
  • * *
  • kill the tweens of a particular object inside the timeline with killTweensOf() or get the tweens of an object * with getTweensOf() or get all the tweens/timelines in the timeline with getChildren()
  • * *
  • set the timeline to repeat any number of times or indefinitely. You can even set a delay * between each repeat cycle and/or cause the repeat cycles to yoyo, appearing to reverse * every other cycle.
  • * *
  • listen for START, UPDATE, REPEAT, REVERSE_COMPLETE, and COMPLETE events.
  • * *
  • get the active tweens in the timeline with getActive().
  • * *
  • add callbacks (function calls) anywhere in the timeline that call a function of your choosing when * the ""virtual playhead"" passes a particular spot.
  • * *
  • Get the currentLabel or find labels at various positions in the timeline * using getLabelAfter() and getLabelBefore()
  • *
* * EXAMPLE:

* * import com.greensock.~~;

* * //create the timeline and add an onComplete call to myFunction when the timeline completes
* var myTimeline:TimelineMax = new TimelineMax({onComplete:myFunction});

* * //add a tween
* myTimeline.append(new TweenLite(mc, 1, {x:200, y:100}));

* * //add another tween at the end of the timeline (makes sequencing easy)
* myTimeline.append(new TweenLite(mc, 0.5, {alpha:0}));

* * //repeat the entire timeline twice
* myTimeline.repeat = 2;

* * //delay the repeat by 0.5 seconds each time.
* myTimeline.repeatDelay = 0.5;

* * //pause the timeline (stop() works too)
* myTimeline.pause();

* * //reverse it anytime...
* myTimeline.reverse();

* * //Add a ""spin"" label 3-seconds into the timeline.
* myTimeline.addLabel(""spin"", 3);

* * //insert a rotation tween at the ""spin"" label (you could also define the insert point as the time instead of a label)
* myTimeline.insert(new TweenLite(mc, 2, {rotation:""360""}), ""spin"");

* * //go to the ""spin"" label and play the timeline from there...
* myTimeline.gotoAndPlay(""spin"");

* * //call myCallbackwhen the ""virtual playhead"" travels past the 1.5-second point. * myTimeline.addCallback(myCallback, 1.5); * * //add a tween to the beginning of the timeline, pushing all the other existing tweens back in time
* myTimeline.prepend(new TweenMax(mc, 1, {tint:0xFF0000}));

* * //nest another TimelineMax inside your timeline...
* var nestedTimeline:TimelineMax = new TimelineMax();
* nestedTimeline.append(new TweenLite(mc2, 1, {x:200}));
* myTimeline.append(nestedTimeline);

* * * insertMultiple() and appendMultiple() provide some very powerful sequencing tools as well, * allowing you to add an Array of tweens/timelines and optionally align them with SEQUENCE or START * modes, and even stagger them if you want. For example, to insert 3 tweens into the timeline, aligning their start times but * staggering them by 0.2 seconds,

* * myTimeline.insertMultiple([new TweenLite(mc, 1, {y:""100""}), * new TweenLite(mc2, 1, {x:120}), * new TweenLite(mc3, 1, {alpha:0.5})], * 0, * TweenAlign.START, * 0.2);

* * You can use the constructor's vars object to do all the setup too, like:

* * var myTimeline:TimelineMax = new TimelineMax({tweens:[new TweenLite(mc1, 1, {y:""100""}), TweenMax.to(mc2, 1, {tint:0xFF0000})], align:TweenAlign.SEQUENCE, onComplete:myFunction, repeat:2, repeatDelay:1});

* * If that confuses you, don't worry. Just use the append(), insert(), and prepend() methods to build your * sequence. But power users will likely appreciate the quick, compact way they can set up sequences now.

* * * NOTES: *
    *
  • TimelineMax automatically inits the OverwriteManager class to prevent unexpected overwriting behavior in sequences. * The default mode is AUTO, but you can set it to whatever you want with OverwriteManager.init() * (see http://www.greensock.com/overwritemanager/)
  • *
  • TimelineMax adds about 4.9k to your SWF (not including OverwriteManager).
  • *
* * Copyright 2011, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. * * @author Jack Doyle, jack@greensock.com **/ public class TimelineMax extends TimelineLite implements IEventDispatcher { /** @private **/ public static const version:Number = 1.66; /** @private **/ protected var _repeat:int; /** @private **/ protected var _repeatDelay:Number; /** @private **/ protected var _cyclesComplete:int; /** @private **/ protected var _dispatcher:EventDispatcher; /** @private **/ protected var _hasUpdateListener:Boolean; /** * Works in conjunction with the repeat property, determining the behavior of each cycle; when yoyo is true, * the timeline will go back and forth, appearing to reverse every other cycle (this has no affect on the reversed property though). * So if repeat is 2 and yoyo is false, it will look like: start - 1 - 2 - 3 - 1 - 2 - 3 - 1 - 2 - 3 - end. * But if repeat is 2 and yoyo is true, it will look like: start - 1 - 2 - 3 - 3 - 2 - 1 - 1 - 2 - 3 - end. **/ public var yoyo:Boolean; /** * Constructor.

* * SPECIAL PROPERTIES
* The following special properties may be passed in via the constructor's vars parameter, like * new TimelineMax({paused:true, onComplete:myFunction, repeat:2, yoyo:true}) * *
    *
  • delay : Number Amount of delay in seconds (or frames for frames-based timelines) before the timeline should begin.
  • * *
  • useFrames : Boolean If useFrames is set to true, the timeline's timing mode will be based on frames. * Otherwise, it will be based on seconds/time. NOTE: a TimelineLite's timing mode is * always determined by its parent timeline.
  • * *
  • paused : Boolean Sets the initial paused state of the timeline (by default, timelines automatically begin playing immediately)
  • * *
  • reversed : Boolean If true, the timeline will be reversed initially. This does NOT force it to the very end and start * playing backwards. It simply affects the orientation of the timeline, so if reversed is set to * true initially, it will appear not to play because it is already at the beginning. To cause it to * play backwards from the end, set reversed to true and then set the currentProgress property to 1 immediately * after creating the timeline.
  • * *
  • tweens : Array To immediately insert several tweens into the timeline, use the tweens special property * to pass in an Array of TweenLite/TweenMax/TimelineLite/TimelineMax instances. You can use this in conjunction * with the align and stagger special properties to set up complex sequences with minimal code. * These values simply get passed to the insertMultiple() method.
  • * *
  • align : String Only used in conjunction with the tweens special property when multiple tweens are * to be inserted immediately through the constructor. The value simply gets passed to the * insertMultiple() method. The default is TweenAlign.NORMAL. Options are: *
      *
    • TweenAlign.SEQUENCE: aligns the tweens one-after-the-other in a sequence
    • *
    • TweenAlign.START: aligns the start times of all of the tweens (ignores delays)
    • *
    • TweenAlign.NORMAL: aligns the start times of all the tweens (honors delays)
    • *
    The align special property does not force all child tweens/timelines to maintain * relative positioning, so for example, if you use TweenAlign.SEQUENCE and then later change the duration * of one of the nested tweens, it does not force all subsequent timelines to change their position * on the timeline. The align special property only affects the alignment of the tweens that are * initially placed into the timeline through the tweens special property of the vars object.
  • * *
  • stagger : Number Only used in conjunction with the tweens special property when multiple tweens are * to be inserted immediately. It staggers the tweens by a set amount of time (in seconds) (or * in frames if useFrames is true). For example, if the stagger value is 0.5 and the align * property is set to TweenAlign.START, the second tween will start 0.5 seconds after the first one * starts, then 0.5 seconds later the third one will start, etc. If the align property is * TweenAlign.SEQUENCE, there would be 0.5 seconds added between each tween. This value simply gets * passed to the insertMultiple() method. Default is 0.
  • * *
  • onStart : Function A function that should be called when the timeline begins (the currentProgress won't necessarily * be zero when onStart is called. For example, if the timeline is created and then its currentProgress * property is immediately set to 0.5 or if its currentTime property is set to something other than zero, * onStart will still get fired because it is the first time the timeline is getting rendered.)
  • * *
  • onStartParams : Array An Array of parameters to pass the onStart function.
  • * *
  • onUpdate : Function A function that should be called every time the timeline's time/position is updated * (on every frame while the timeline is active)
  • * *
  • onUpdateParams : Array An Array of parameters to pass the onUpdate function
  • * *
  • onComplete : Function A function that should be called when the timeline has finished
  • * *
  • onCompleteParams : Array An Array of parameters to pass the onComplete function
  • * *
  • onReverseComplete : Function A function that should be called when the timeline has reached its starting point again after having been reversed
  • * *
  • onReverseCompleteParams : Array An Array of parameters to pass the onReverseComplete functions
  • * *
  • onRepeat : Function A function that should be called every time the timeline repeats
  • * *
  • onRepeatParams : Array An Array of parameters to pass the onRepeat function
  • * *
  • autoRemoveChildren : Boolean If autoRemoveChildren is set to true, as soon as child tweens/timelines complete, * they will automatically get killed/removed. This is normally undesireable because * it prevents going backwards in time (like if you want to reverse() or set the * currentProgress value to a lower value, etc.). It can, however, improve speed and memory * management. TweenLite's root timelines use autoRemoveChildren:true.
  • * *
  • repeat : int Number of times that the timeline should repeat. To repeat indefinitely, use -1.
  • * *
  • repeatDelay : Number Amount of time in seconds (or frames for frames-based timelines) between repeats.
  • * *
  • yoyo : Boolean Works in conjunction with the repeat property, determining the behavior of each * cycle. When yoyo is true, the timeline will go back and forth, appearing to reverse * every other cycle (this has no affect on the reversed property though). So if repeat is * 2 and yoyo is false, it will look like: start - 1 - 2 - 3 - 1 - 2 - 3 - 1 - 2 - 3 - end. But * if repeat is 2 and yoyo is true, it will look like: start - 1 - 2 - 3 - 3 - 2 - 1 - 1 - 2 - 3 - end.
  • * *
  • onStartListener : Function A function to which the TimelineMax instance should dispatch a TweenEvent when it begins. * This is the same as doing myTimeline.addEventListener(TweenEvent.START, myFunction);
  • * *
  • onUpdateListener : Function A function to which the TimelineMax instance should dispatch a TweenEvent every time it * updates values. This is the same as doing myTimeline.addEventListener(TweenEvent.UPDATE, myFunction);
  • * *
  • onCompleteListener : Function A function to which the TimelineMax instance should dispatch a TweenEvent when it completes. * This is the same as doing myTimeline.addEventListener(TweenEvent.COMPLETE, myFunction);
  • *
* * @param vars optionally pass in special properties like useFrames, onComplete, onCompleteParams, onUpdate, onUpdateParams, onStart, onStartParams, tweens, align, stagger, delay, autoRemoveChildren, onCompleteListener, onStartListener, onUpdateListener, repeat, repeatDelay, and/or yoyo. */ public function TimelineMax(vars:Object=null) { super(vars); _repeat = (this.vars.repeat) ? Number(this.vars.repeat) : 0; _repeatDelay = (this.vars.repeatDelay) ? Number(this.vars.repeatDelay) : 0; _cyclesComplete = 0; this.yoyo = Boolean(this.vars.yoyo == true); this.cacheIsDirty = true; if (this.vars.onCompleteListener != null || this.vars.onUpdateListener != null || this.vars.onStartListener != null || this.vars.onRepeatListener != null || this.vars.onReverseCompleteListener != null) { initDispatcher(); } } /** * If you want a function to be called at a particular time or label, use addCallback. When you add * a callback, it is technically considered a zero-duration tween, so if you getChildren() there will be * a tween returned for each callback. You can discern a callback from other tweens by the fact that * their target is a function and the duration is zero. * * @param function the function to be called * @param timeOrLabel the time in seconds (or frames for frames-based timelines) or label at which the callback should be inserted. For example, myTimeline.addCallback(myFunction, 3) would call myFunction() 3-seconds into the timeline, and myTimeline.addCallback(myFunction, ""myLabel"") would call it at the ""myLabel"" label. * @param params an Array of parameters to pass the callback * @return TweenLite instance */ public function addCallback(callback:Function, timeOrLabel:*, params:Array=null):TweenLite { var cb:TweenLite = new TweenLite(callback, 0, {onComplete:callback, onCompleteParams:params, overwrite:0, immediateRender:false}); insert(cb, timeOrLabel); return cb; } /** * Removes a callback from a particular time or label. If timeOrLabel is null, all callbacks of that * particular function are removed from the timeline. * * @param function callback function to be removed * @param timeOrLabel the time in seconds (or frames for frames-based timelines) or label from which the callback should be removed. For example, myTimeline.removeCallback(myFunction, 3) would remove the callback from 3-seconds into the timeline, and myTimeline.removeCallback(myFunction, ""myLabel"") would remove it from the ""myLabel"" label, and myTimeline.removeCallback(myFunction, null) would remove ALL callbacks of that function regardless of where they are on the timeline. * @return true if any callbacks were successfully found and removed. false otherwise. */ public function removeCallback(callback:Function, timeOrLabel:*=null):Boolean { if (timeOrLabel == null) { return killTweensOf(callback, false); } else { if (typeof(timeOrLabel) == ""string"") { if (!(timeOrLabel in _labels)) { return false; } timeOrLabel = _labels[timeOrLabel]; } var a:Array = getTweensOf(callback, false), success:Boolean; var i:int = a.length; while (--i > -1) { if (a[i].cachedStartTime == timeOrLabel) { remove(a[i] as TweenCore); success = true; } } return success; } } /** * Creates a linear tween that essentially scrubs the playhead to a particular time or label and then stops. For * example, to make the TimelineMax play to the ""myLabel2"" label, simply do:

* * myTimeline.tweenTo(""myLabel2"");

* * If you want advanced control over the tween, like adding an onComplete or changing the ease or adding a delay, * just pass in a vars object with the appropriate properties. For example, to tween to the 5-second point on the * timeline and then call a function named myFunction and pass in a parameter that's references this * TimelineMax and use a Strong.easeOut ease, you'd do:

* * myTimeline.tweenTo(5, {onComplete:myFunction, onCompleteParams:[myTimeline], ease:Strong.easeOut});

* * Remember, this method simply creates a TweenLite instance that tweens the currentTime property of your timeline. * So you can store a reference to that tween if you want, and you can kill() it anytime. Also note that tweenTo() * does NOT affect the timeline's reversed property. So if your timeline is oriented normally * (not reversed) and you tween to a time/label that precedes the current time, it will appear to go backwards * but the reversed property will not change to true. Also note that tweenTo() * pauses the timeline immediately before tweening its currentTime property, and it stays paused after the tween completes. * If you need to resume playback, you could always use an onComplete to call the resume() method.

* * If you plan to sequence multiple playhead tweens one-after-the-other, it is typically better to use * tweenFromTo() so that you can define the starting point and ending point, allowing the * duration to be accurately determined immediately. * * @see #tweenFromTo() * @param timeOrLabel The destination time in seconds (or frame if the timeline is frames-based) or label to which the timeline should play. For example, myTimeline.tweenTo(5) would play from wherever the timeline is currently to the 5-second point whereas myTimeline.tweenTo(""myLabel"") would play to wherever ""myLabel"" is on the timeline. * @param vars An optional vars object that will be passed to the TweenLite instance. This allows you to define an onComplete, ease, delay, or any other TweenLite special property. onInit is the only special property that is not available (tweenTo() sets it internally) * @return TweenLite instance that handles tweening the timeline to the desired time/label. */ public function tweenTo(timeOrLabel:*, vars:Object=null):TweenLite { var varsCopy:Object = {ease:easeNone, overwrite:2, useFrames:this.useFrames, immediateRender:false}; for (var p:String in vars) { varsCopy[p] = vars[p]; } varsCopy.onInit = onInitTweenTo; varsCopy.onInitParams = [null, this, NaN]; varsCopy.currentTime = parseTimeOrLabel(timeOrLabel); var tl:TweenLite = new TweenLite(this, (Math.abs(Number(varsCopy.currentTime) - this.cachedTime) / this.cachedTimeScale) || 0.001, varsCopy); tl.vars.onInitParams[0] = tl; return tl; } /** * Creates a linear tween that essentially scrubs the playhead from a particular time or label to another * time or label and then stops. If you plan to sequence multiple playhead tweens one-after-the-other, * tweenFromTo() is better to use than tweenTo() because it allows the duration * to be determined immediately, ensuring that subsequent tweens that are appended to a sequence are * positioned appropriately. For example, to make the TimelineMax play from the label ""myLabel1"" to the ""myLabel2"" * label, and then from ""myLabel2"" back to the beginning (a time of 0), simply do:

* * var playheadTweens:TimelineMax = new TimelineMax();
* playheadTweens.append( myTimeline.tweenFromTo(""myLabel1"", ""myLabel2"") );
* playheadTweens.append( myTimeline.tweenFromTo(""myLabel2"", 0);

* * If you want advanced control over the tween, like adding an onComplete or changing the ease or adding a delay, * just pass in a vars object with the appropriate properties. For example, to tween from the start (0) to the * 5-second point on the timeline and then call a function named myFunction and pass in a parameter * that's references this TimelineMax and use a Strong.easeOut ease, you'd do:

* * myTimeline.tweenFromTo(0, 5, {onComplete:myFunction, onCompleteParams:[myTimeline], ease:Strong.easeOut});

* * Remember, this method simply creates a TweenLite instance that tweens the currentTime property of your timeline. * So you can store a reference to that tween if you want, and you can kill() it anytime. Also note that tweenFromTo() * does NOT affect the timeline's reversed property. So if your timeline is oriented normally * (not reversed) and you tween to a time/label that precedes the current time, it will appear to go backwards * but the reversed property will not change to true. Also note that tweenFromTo() * pauses the timeline immediately before tweening its currentTime property, and it stays paused after the tween completes. * If you need to resume playback, you could always use an onComplete to call the resume() method. * * @see #tweenTo() * @param fromTimeOrLabel The beginning time in seconds (or frame if the timeline is frames-based) or label from which the timeline should play. For example, myTimeline.tweenTo(0, 5) would play from 0 (the beginning) to the 5-second point whereas myTimeline.tweenFromTo(""myLabel1"", ""myLabel2"") would play from ""myLabel1"" to ""myLabel2"". * @param toTimeOrLabel The destination time in seconds (or frame if the timeline is frames-based) or label to which the timeline should play. For example, myTimeline.tweenTo(0, 5) would play from 0 (the beginning) to the 5-second point whereas myTimeline.tweenFromTo(""myLabel1"", ""myLabel2"") would play from ""myLabel1"" to ""myLabel2"". * @param vars An optional vars object that will be passed to the TweenLite instance. This allows you to define an onComplete, ease, delay, or any other TweenLite special property. onInit is the only special property that is not available (tweenFromTo() sets it internally) * @return TweenLite instance that handles tweening the timeline between the desired times/labels. */ public function tweenFromTo(fromTimeOrLabel:*, toTimeOrLabel:*, vars:Object=null):TweenLite { var tl:TweenLite = tweenTo(toTimeOrLabel, vars); tl.vars.onInitParams[2] = parseTimeOrLabel(fromTimeOrLabel); tl.duration = Math.abs(Number(tl.vars.currentTime) - tl.vars.onInitParams[2]) / this.cachedTimeScale; return tl; } /** @private **/ private static function onInitTweenTo(tween:TweenLite, timeline:TimelineMax, fromTime:Number):void { timeline.paused = true; if (!isNaN(fromTime)) { timeline.currentTime = fromTime; } if (tween.vars.currentTime != timeline.currentTime) { //don't make the duration zero - if it's supposed to be zero, don't worry because it's already initting the tween and will complete immediately, effectively making the duration zero anyway. If we make duration zero, the tween won't run at all. tween.duration = Math.abs(Number(tween.vars.currentTime) - timeline.currentTime) / timeline.cachedTimeScale; } } /** @private **/ private static function easeNone(t:Number, b:Number, c:Number, d:Number):Number { return t / d; } /** @private **/ override public function renderTime(time:Number, suppressEvents:Boolean=false, force:Boolean=false):void { if (this.gc) { this.setEnabled(true, false); } else if (!this.active && !this.cachedPaused) { this.active = true; //so that if the user renders a tween (as opposed to the timeline rendering it), the timeline is forced to re-render and align it with the proper time/frame on the next rendering cycle. Maybe the tween already finished but the user manually re-renders it as halfway done. } var totalDur:Number = (this.cacheIsDirty) ? this.totalDuration : this.cachedTotalDuration, prevTime:Number = this.cachedTime, prevTotalTime:Number = this.cachedTotalTime, prevStart:Number = this.cachedStartTime, prevTimeScale:Number = this.cachedTimeScale, tween:TweenCore, isComplete:Boolean, rendered:Boolean, repeated:Boolean, next:TweenCore, dur:Number, prevPaused:Boolean = this.cachedPaused; if (time >= totalDur) { if (_rawPrevTime <= totalDur && _rawPrevTime != time) { this.cachedTotalTime = totalDur; if (!this.cachedReversed && this.yoyo && _repeat % 2 != 0) { this.cachedTime = 0; forceChildrenToBeginning(0, suppressEvents); } else { this.cachedTime = this.cachedDuration; forceChildrenToEnd(this.cachedDuration, suppressEvents); } isComplete = !this.hasPausedChild(); rendered = true; if (this.cachedDuration == 0 && isComplete && (time == 0 || _rawPrevTime < 0)) { //In order to accommodate zero-duration timelines, we must discern the momentum/direction of time in order to render values properly when the ""playhead"" goes past 0 in the forward direction or lands directly on it, and also when it moves past it in the backward direction (from a postitive time to a negative time). force = true; } } } else if (time <= 0) { if (time < 0) { this.active = false; if (this.cachedDuration == 0 && _rawPrevTime >= 0) { //In order to accommodate zero-duration timelines, we must discern the momentum/direction of time in order to render values properly when the ""playhead"" goes past 0 in the forward direction or lands directly on it, and also when it moves past it in the backward direction (from a postitive time to a negative time). force = true; isComplete = true; } } else if (time == 0 && !this.initted) { force = true; } if (_rawPrevTime >= 0 && _rawPrevTime != time) { this.cachedTotalTime = 0; this.cachedTime = 0; forceChildrenToBeginning(0, suppressEvents); rendered = true; if (this.cachedReversed) { isComplete = true; } } } else { this.cachedTotalTime = this.cachedTime = time; } _rawPrevTime = time; if (_repeat != 0) { var cycleDuration:Number = this.cachedDuration + _repeatDelay; var prevCycles:int = _cyclesComplete; _cyclesComplete = (this.cachedTotalTime / cycleDuration) >> 0; //rounds result, like int() if (_cyclesComplete == this.cachedTotalTime / cycleDuration) { _cyclesComplete--; //otherwise when rendered exactly at the end time, it will act as though it is repeating (at the beginning) } if (prevCycles != _cyclesComplete) { repeated = true; } if (isComplete) { if (this.yoyo && _repeat % 2) { this.cachedTime = 0; } } else if (time > 0) { this.cachedTime = ((this.cachedTotalTime / cycleDuration) - _cyclesComplete) * cycleDuration; //originally this.cachedTotalTime % cycleDuration but floating point errors caused problems, so I normalized it. (4 % 0.8 should be 0 but Flash reports it as 0.79999999!) if (this.yoyo && _cyclesComplete % 2) { this.cachedTime = this.cachedDuration - this.cachedTime; } else if (this.cachedTime >= this.cachedDuration) { this.cachedTime = this.cachedDuration; } if (this.cachedTime < 0) { this.cachedTime = 0; } } else { _cyclesComplete = 0; } if (repeated && !isComplete && (this.cachedTime != prevTime || force)) { /* make sure children at the end/beginning of the timeline are rendered properly. If, for example, a 3-second long timeline rendered at 2.9 seconds previously, and now renders at 3.2 seconds (which would get transated to 2.8 seconds if the timeline yoyos or 0.2 seconds if it just repeats), there could be a callback or a short tween that's at 2.95 or 3 seconds in which wouldn't render. So we need to push the timeline to the end (and/or beginning depending on its yoyo value). */ var forward:Boolean = Boolean(!this.yoyo || (_cyclesComplete % 2 == 0)); var prevForward:Boolean = Boolean(!this.yoyo || (prevCycles % 2 == 0)); var wrap:Boolean = Boolean(forward == prevForward); if (prevCycles > _cyclesComplete) { prevForward = !prevForward; } if (prevForward) { prevTime = forceChildrenToEnd(this.cachedDuration, suppressEvents); if (wrap) { prevTime = forceChildrenToBeginning(0, true); } } else { prevTime = forceChildrenToBeginning(0, suppressEvents); if (wrap) { prevTime = forceChildrenToEnd(this.cachedDuration, true); } } rendered = false; } } if (this.cachedTotalTime == prevTotalTime && !force) { return; } else if (!this.initted) { this.initted = true; } if (prevTotalTime == 0 && this.cachedTotalTime != 0 && !suppressEvents) { if (this.vars.onStart) { this.vars.onStart.apply(null, this.vars.onStartParams); } if (_dispatcher) { _dispatcher.dispatchEvent(new TweenEvent(TweenEvent.START)); } } if (rendered) { //already rendered, so ignore } else if (this.cachedTime - prevTime > 0) { tween = _firstChild; while (tween) { next = tween.nextNode; //record it here because the value could change after rendering... if (this.cachedPaused && !prevPaused) { //in case a tween pauses the timeline when rendering break; } else if (tween.active || (!tween.cachedPaused && tween.cachedStartTime <= this.cachedTime && !tween.gc)) { if (!tween.cachedReversed) { tween.renderTime((this.cachedTime - tween.cachedStartTime) * tween.cachedTimeScale, suppressEvents, false); } else { dur = (tween.cacheIsDirty) ? tween.totalDuration : tween.cachedTotalDuration; tween.renderTime(dur - ((this.cachedTime - tween.cachedStartTime) * tween.cachedTimeScale), suppressEvents, false); } } tween = next; } } else { tween = _lastChild; while (tween) { next = tween.prevNode; //record it here because the value could change after rendering... if (this.cachedPaused && !prevPaused) { //in case a tween pauses the timeline when rendering break; } else if (tween.active || (!tween.cachedPaused && tween.cachedStartTime <= prevTime && !tween.gc)) { if (!tween.cachedReversed) { tween.renderTime((this.cachedTime - tween.cachedStartTime) * tween.cachedTimeScale, suppressEvents, false); } else { dur = (tween.cacheIsDirty) ? tween.totalDuration : tween.cachedTotalDuration; tween.renderTime(dur - ((this.cachedTime - tween.cachedStartTime) * tween.cachedTimeScale), suppressEvents, false); } } tween = next; } } if (_hasUpdate && !suppressEvents) { this.vars.onUpdate.apply(null, this.vars.onUpdateParams); } if (_hasUpdateListener && !suppressEvents) { _dispatcher.dispatchEvent(new TweenEvent(TweenEvent.UPDATE)); } if (repeated && !suppressEvents) { if (this.vars.onRepeat) { this.vars.onRepeat.apply(null, this.vars.onRepeatParams); } if (_dispatcher) { _dispatcher.dispatchEvent(new TweenEvent(TweenEvent.REPEAT)); } } if (isComplete && (prevStart == this.cachedStartTime || prevTimeScale != this.cachedTimeScale) && (totalDur >= this.totalDuration || this.cachedTime == 0)) { //if one of the tweens that was rendered altered this timeline's startTime (like if an onComplete reversed the timeline) or if it added more tweens to the timeline, we shouldn't run complete() because it probably isn't complete. If it is, don't worry, because whatever call altered the startTime would have called complete() if it was necessary at the new time. The only exception is the timeScale property. complete(true, suppressEvents); } } /** * Forces the timeline to completion. * * @param skipRender to skip rendering the final state of the timeline, set skipRender to true. * @param suppressEvents If true, no events or callbacks will be triggered for this render (like onComplete, onUpdate, onReverseComplete, etc.) */ override public function complete(skipRender:Boolean=false, suppressEvents:Boolean=false):void { super.complete(skipRender, suppressEvents); if (_dispatcher && !suppressEvents) { if (this.cachedReversed && this.cachedTotalTime == 0 && this.cachedDuration != 0) { _dispatcher.dispatchEvent(new TweenEvent(TweenEvent.REVERSE_COMPLETE)); } else { _dispatcher.dispatchEvent(new TweenEvent(TweenEvent.COMPLETE)); } } } /** * Returns the tweens/timelines that are currently active in the timeline. * * @param nested determines whether or not tweens and/or timelines that are inside nested timelines should be returned. If you only want the ""top level"" tweens/timelines, set this to false. * @param tweens determines whether or not tweens (TweenLite and TweenMax instances) should be included in the results * @param timelines determines whether or not timelines (TimelineLite and TimelineMax instances) should be included in the results * @return an Array of active tweens/timelines */ public function getActive(nested:Boolean=true, tweens:Boolean=true, timelines:Boolean=false):Array { var a:Array = [], all:Array = getChildren(nested, tweens, timelines), i:int; var l:int = all.length; var cnt:int = 0; for (i = 0; i < l; i += 1) { if (TweenCore(all[i]).active) { a[cnt++] = all[i]; } } return a; } /** @inheritDoc **/ override public function invalidate():void { _repeat = (this.vars.repeat) ? Number(this.vars.repeat) : 0; _repeatDelay = (this.vars.repeatDelay) ? Number(this.vars.repeatDelay) : 0; this.yoyo = Boolean(this.vars.yoyo == true); if (this.vars.onCompleteListener != null || this.vars.onUpdateListener != null || this.vars.onStartListener != null || this.vars.onRepeatListener != null || this.vars.onReverseCompleteListener != null) { initDispatcher(); } setDirtyCache(true); super.invalidate(); } /** * Returns the next label (if any) that occurs AFTER the time parameter. It makes no difference * if the timeline is reversed. A label that is positioned exactly at the same time as the time * parameter will be ignored. * * @param time Time after which the label is searched for. If you do not pass a time in, the currentTime will be used. * @return Name of the label that is after the time passed to getLabelAfter() */ public function getLabelAfter(time:Number=NaN):String { if (!time && time != 0) { //faster than isNan() time = this.cachedTime; } var labels:Array = getLabelsArray(); var l:int = labels.length; for (var i:int = 0; i < l; i += 1) { if (labels[i].time > time) { return labels[i].name; } } return null; } /** * Returns the previous label (if any) that occurs BEFORE the time parameter. It makes no difference * if the timeline is reversed. A label that is positioned exactly at the same time as the time * parameter will be ignored. * * @param time Time before which the label is searched for. If you do not pass a time in, the currentTime will be used. * @return Name of the label that is before the time passed to getLabelBefore() */ public function getLabelBefore(time:Number=NaN):String { if (!time && time != 0) { //faster than isNan() time = this.cachedTime; } var labels:Array = getLabelsArray(); var i:int = labels.length; while (--i > -1) { if (labels[i].time < time) { return labels[i].name; } } return null; } /** @private Returns an Array of label objects, each with a ""time"" and ""name"" property, in the order that they occur in the timeline. **/ protected function getLabelsArray():Array { var a:Array = []; for (var p:String in _labels) { a[a.length] = {time:_labels[p], name:p}; } a.sortOn(""time"", Array.NUMERIC); return a; } //---- EVENT DISPATCHING ---------------------------------------------------------------------------------------------------------- /** @private **/ protected function initDispatcher():void { if (_dispatcher == null) { _dispatcher = new EventDispatcher(this); } if (this.vars.onStartListener is Function) { _dispatcher.addEventListener(TweenEvent.START, this.vars.onStartListener, false, 0, true); } if (this.vars.onUpdateListener is Function) { _dispatcher.addEventListener(TweenEvent.UPDATE, this.vars.onUpdateListener, false, 0, true); _hasUpdateListener = true; } if (this.vars.onCompleteListener is Function) { _dispatcher.addEventListener(TweenEvent.COMPLETE, this.vars.onCompleteListener, false, 0, true); } if (this.vars.onRepeatListener is Function) { _dispatcher.addEventListener(TweenEvent.REPEAT, this.vars.onRepeatListener, false, 0, true); } if (this.vars.onReverseCompleteListener is Function) { _dispatcher.addEventListener(TweenEvent.REVERSE_COMPLETE, this.vars.onReverseCompleteListener, false, 0, true); } } /** @private **/ public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void { if (_dispatcher == null) { initDispatcher(); } if (type == TweenEvent.UPDATE) { _hasUpdateListener = true; } _dispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference); } /** @private **/ public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void { if (_dispatcher != null) { _dispatcher.removeEventListener(type, listener, useCapture); } } /** @private **/ public function hasEventListener(type:String):Boolean { return (_dispatcher == null) ? false : _dispatcher.hasEventListener(type); } /** @private **/ public function willTrigger(type:String):Boolean { return (_dispatcher == null) ? false : _dispatcher.willTrigger(type); } /** @private **/ public function dispatchEvent(e:Event):Boolean { return (_dispatcher == null) ? false : _dispatcher.dispatchEvent(e); } //---- GETTERS / SETTERS ------------------------------------------------------------------------------------------------------- /** * Value between 0 and 1 indicating the overall progress of the timeline according to its totalDuration * where 0 is at the beginning, 0.5 is halfway finished, and 1 is finished. currentProgress, * by contrast, describes the progress according to the timeline's duration which does not * include repeats and repeatDelays. For example, if a TimelineMax instance is set * to repeat once, at the end of the first cycle totalProgress would only be 0.5 * whereas currentProgress would be 1. If you tracked both properties over the course of the * tween, you'd see currentProgress go from 0 to 1 twice (once for each cycle) in the same * time it takes the totalProgress property to go from 0 to 1 once. **/ public function get totalProgress():Number { return this.cachedTotalTime / this.totalDuration; } public function set totalProgress(n:Number):void { setTotalTime(this.totalDuration * n, false); } /** * Duration of the timeline in seconds (or frames for frames-based timelines) including any repeats * or repeatDelays. ""duration"", by contrast, does NOT include repeats and repeatDelays. **/ override public function get totalDuration():Number { if (this.cacheIsDirty) { var temp:Number = super.totalDuration; //just forces refresh //Instead of Infinity, we use 999999999999 so that we can accommodate reverses. this.cachedTotalDuration = (_repeat == -1) ? 999999999999 : this.cachedDuration * (_repeat + 1) + (_repeatDelay * _repeat); } return this.cachedTotalDuration; } /** @private **/ override public function set currentTime(n:Number):void { if (_cyclesComplete == 0) { setTotalTime(n, false); } else if (this.yoyo && (_cyclesComplete % 2 == 1)) { setTotalTime((this.duration - n) + (_cyclesComplete * (this.cachedDuration + _repeatDelay)), false); } else { setTotalTime(n + (_cyclesComplete * (this.duration + _repeatDelay)), false); } } /** Number of times that the timeline should repeat; -1 repeats indefinitely. **/ public function get repeat():int { return _repeat; } public function set repeat(n:int):void { _repeat = n; setDirtyCache(true); } /** Amount of time in seconds (or frames for frames-based timelines) between repeats **/ public function get repeatDelay():Number { return _repeatDelay; } public function set repeatDelay(n:Number):void { _repeatDelay = n; setDirtyCache(true); } /** The closest label that is at or before the current time. **/ public function get currentLabel():String { return getLabelBefore(this.cachedTime + 0.00000001); } } }",12121,False,2056.4616541058144,median "/* PowerSaveTest.ino This test will turn on and off your display for two seconds. If the text ""power off"" is visible on your display, then power save mode does not work with your display. Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1306_72X40_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_WS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_RAYSTAR_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_RAYSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7528_ERC16064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7528_ERC16064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_KS0713_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_KS0713_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7567_HEM6432_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_IST7920_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_IST7920_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_DEM240064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1617_JLX128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1617_JLX128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list void setup(void) { u8g2.begin(); u8g2.setFont(u8g2_font_6x10_tr); } void draw(const char *s) { u8g2.firstPage(); do { u8g2.drawStr(2,15,""PowerSaveTest""); u8g2.drawStr(2,30,s); u8g2.drawFrame(0,0,u8g2.getDisplayWidth(),u8g2.getDisplayHeight() ); } while ( u8g2.nextPage() ); delay(2000); } void loop(void) { u8g2.setPowerSave(0); draw(""power on / x""); u8g2.setPowerSave(1); draw(""power off / x""); u8g2.setPowerSave(0); draw(""power on / +""); u8g2.setPowerSave(1); draw(""power off / +""); } ",16131,True,4903.104618301965,median "/** * FlxControlHandler * -- Part of the Flixel Power Tools set * * v1.8 Added isPressedUp/Down/Left/Right handlers * v1.7 Modified update function so gravity is applied constantly * v1.6 Thrust and Reverse complete, final few rotation bugs solved. Sounds hooked in for fire, jump, walk and thrust * v1.5 Full support for rotation with min/max angle limits * v1.4 Fixed bug in runFire causing fireRate to be ignored * v1.3 Major refactoring and lots of new enhancements * v1.2 First real version deployed to dev * v1.1 Updated for the Flixel 2.5 Plugin system * * @version 1.8 - August 16th 2011 * @link http://www.photonstorm.com * @author Richard Davey / Photon Storm */ package org.flixel.plugin.photonstorm { import flash.geom.Rectangle; import org.flixel.*; import flash.utils.getTimer; /** * Makes controlling an FlxSprite with the keyboard a LOT easier and quicker to set-up!
* Sometimes it's hard to know what values to set, especially if you want gravity, jumping, sliding, etc.
* This class helps sort that - and adds some cool extra functionality too :) * * TODO * ---- * Allow to bind Fire Button to FlxWeapon * Allow to enable multiple key sets. So cursors and WASD together * Hot Keys * Binding of sound effects to keys (seperate from setSounds? as those are event based) * If moving diagonally compensate speed parameter (times x,y velocities by 0.707 or cos/sin(45)) * Specify animation frames to play based on velocity * Variable gravity (based on height, the higher the stronger the effect) */ public class FlxControlHandler { // Used by the FlxControl plugin public var enabled:Boolean = false; private var entity:FlxSprite = null; private var bounds:Rectangle; private var up:Boolean; private var down:Boolean; private var left:Boolean; private var right:Boolean; private var fire:Boolean; private var altFire:Boolean; private var jump:Boolean; private var altJump:Boolean; private var xFacing:Boolean; private var yFacing:Boolean; private var rotateAntiClockwise:Boolean; private var rotateClockwise:Boolean; private var upMoveSpeed:int; private var downMoveSpeed:int; private var leftMoveSpeed:int; private var rightMoveSpeed:int; private var thrustSpeed:int; private var reverseSpeed:int; // Rotation private var thrustEnabled:Boolean; private var reverseEnabled:Boolean; private var isRotating:Boolean; private var antiClockwiseRotationSpeed:Number; private var clockwiseRotationSpeed:Number; private var enforceAngleLimits:Boolean; private var minAngle:int; private var maxAngle:int; private var capAngularVelocity:Boolean; private var xSpeedAdjust:Number = 0; private var ySpeedAdjust:Number = 0; private var gravityX:int = 0; private var gravityY:int = 0; private var fireRate:int; // The ms delay between firing when the key is held down private var nextFireTime:int; // The internal time when they can next fire private var lastFiredTime:int; // The internal time of when when they last fired private var fireKeyMode:uint; // The fire key mode private var fireCallback:Function; // A function to call every time they fire private var jumpHeight:int; // The pixel height amount they jump (drag and gravity also both influence this) private var jumpRate:int; // The ms delay between jumping when the key is held down private var jumpKeyMode:uint; // The jump key mode private var nextJumpTime:int; // The internal time when they can next jump private var lastJumpTime:int; // The internal time of when when they last jumped private var jumpFromFallTime:int; // A short window of opportunity for them to jump having just fallen off the edge of a surface private var extraSurfaceTime:int; // Internal time of when they last collided with a valid jumpSurface private var jumpSurface:uint; // The surfaces from FlxObject they can jump from (i.e. FlxObject.FLOOR) private var jumpCallback:Function; // A function to call every time they jump private var movement:int; private var stopping:int; private var rotation:int; private var rotationStopping:int; private var capVelocity:Boolean; private var hotkeys:Array; // TODO private var upKey:String; private var downKey:String; private var leftKey:String; private var rightKey:String; private var fireKey:String; private var altFireKey:String; // TODO private var jumpKey:String; private var altJumpKey:String; // TODO private var antiClockwiseKey:String; private var clockwiseKey:String; private var thrustKey:String; private var reverseKey:String; // Sounds private var jumpSound:FlxSound = null; private var fireSound:FlxSound = null; private var walkSound:FlxSound = null; private var thrustSound:FlxSound = null; // Helpers public var isPressedUp:Boolean = false; public var isPressedDown:Boolean = false; public var isPressedLeft:Boolean = false; public var isPressedRight:Boolean = false; /** * The ""Instant"" Movement Type means the sprite will move at maximum speed instantly, and will not ""accelerate"" (or speed-up) before reaching that speed. */ public static const MOVEMENT_INSTANT:int = 0; /** * The ""Accelerates"" Movement Type means the sprite will accelerate until it reaches maximum speed. */ public static const MOVEMENT_ACCELERATES:int = 1; /** * The ""Instant"" Stopping Type means the sprite will stop immediately when no direction keys are being pressed, there will be no deceleration. */ public static const STOPPING_INSTANT:int = 0; /** * The ""Decelerates"" Stopping Type means the sprite will start decelerating when no direction keys are being pressed. Deceleration continues until the speed reaches zero. */ public static const STOPPING_DECELERATES:int = 1; /** * The ""Never"" Stopping Type means the sprite will never decelerate, any speed built up will be carried on and never reduce. */ public static const STOPPING_NEVER:int = 2; /** * The ""Instant"" Movement Type means the sprite will rotate at maximum speed instantly, and will not ""accelerate"" (or speed-up) before reaching that speed. */ public static const ROTATION_INSTANT:int = 0; /** * The ""Accelerates"" Rotaton Type means the sprite will accelerate until it reaches maximum rotation speed. */ public static const ROTATION_ACCELERATES:int = 1; /** * The ""Instant"" Stopping Type means the sprite will stop rotating immediately when no rotation keys are being pressed, there will be no deceleration. */ public static const ROTATION_STOPPING_INSTANT:int = 0; /** * The ""Decelerates"" Stopping Type means the sprite will start decelerating when no rotation keys are being pressed. Deceleration continues until rotation speed reaches zero. */ public static const ROTATION_STOPPING_DECELERATES:int = 1; /** * The ""Never"" Stopping Type means the sprite will never decelerate, any speed built up will be carried on and never reduce. */ public static const ROTATION_STOPPING_NEVER:int = 2; /** * This keymode fires for as long as the key is held down */ public static const KEYMODE_PRESSED:int = 0; /** * This keyboard fires when the key has just been pressed down, and not again until it is released and re-pressed */ public static const KEYMODE_JUST_DOWN:int = 1; /** * This keyboard fires only when the key has been pressed and then released again */ public static const KEYMODE_RELEASED:int = 2; /** * Sets the FlxSprite to be controlled by this class, and defines the initial movement and stopping types.
* After creating an instance of this class you should call setMovementSpeed, and one of the enableXControl functions if you need more than basic cursors. * * @param source The FlxSprite you want this class to control. It can only control one FlxSprite at once. * @param movementType Set to either MOVEMENT_INSTANT or MOVEMENT_ACCELERATES * @param stoppingType Set to STOPPING_INSTANT, STOPPING_DECELERATES or STOPPING_NEVER * @param updateFacing If true it sets the FlxSprite.facing value to the direction pressed (default false) * @param enableArrowKeys If true it will enable all arrow keys (default) - see setCursorControl for more fine-grained control * * @see setMovementSpeed */ public function FlxControlHandler(source:FlxSprite, movementType:int, stoppingType:int, updateFacing:Boolean = false, enableArrowKeys:Boolean = true) { entity = source; movement = movementType; stopping = stoppingType; xFacing = updateFacing; yFacing = updateFacing; up = false; down = false; left = false; right = false; thrustEnabled = false; isRotating = false; enforceAngleLimits = false; rotation = ROTATION_INSTANT; rotationStopping = ROTATION_STOPPING_INSTANT; if (enableArrowKeys) { setCursorControl(); } enabled = true; } /** * Set the speed at which the sprite will move when a direction key is pressed.
* All values are given in pixels per second. So an xSpeed of 100 would move the sprite 100 pixels in 1 second (1000ms)
* Due to the nature of the internal Flash timer this amount is not 100% accurate and will vary above/below the desired distance by a few pixels.
* * If you need different speed values for left/right or up/down then use setAdvancedMovementSpeed * * @param xSpeed The speed in pixels per second in which the sprite will move/accelerate horizontally * @param ySpeed The speed in pixels per second in which the sprite will move/accelerate vertically * @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally * @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically * @param xDeceleration A deceleration speed in pixels per second to apply to the sprites horizontal movement (default 0) * @param yDeceleration A deceleration speed in pixels per second to apply to the sprites vertical movement (default 0) */ public function setMovementSpeed(xSpeed:uint, ySpeed:uint, xSpeedMax:uint, ySpeedMax:uint, xDeceleration:uint = 0, yDeceleration:uint = 0):void { leftMoveSpeed = -xSpeed; rightMoveSpeed = xSpeed; upMoveSpeed = -ySpeed; downMoveSpeed = ySpeed; setMaximumSpeed(xSpeedMax, ySpeedMax); setDeceleration(xDeceleration, yDeceleration); } /** * If you know you need the same value for the acceleration, maximum speeds and (optionally) deceleration then this is a quick way to set them. * * @param speed The speed in pixels per second in which the sprite will move/accelerate/decelerate * @param acceleration If true it will set the speed value as the deceleration value (default) false will leave deceleration disabled */ public function setStandardSpeed(speed:uint, acceleration:Boolean = true):void { if (acceleration) { setMovementSpeed(speed, speed, speed, speed, speed, speed); } else { setMovementSpeed(speed, speed, speed, speed); } } /** * Set the speed at which the sprite will move when a direction key is pressed.
* All values are given in pixels per second. So an xSpeed of 100 would move the sprite 100 pixels in 1 second (1000ms)
* Due to the nature of the internal Flash timer this amount is not 100% accurate and will vary above/below the desired distance by a few pixels.
* * If you don't need different speed values for every direction on its own then use setMovementSpeed * * @param leftSpeed The speed in pixels per second in which the sprite will move/accelerate to the left * @param rightSpeed The speed in pixels per second in which the sprite will move/accelerate to the right * @param upSpeed The speed in pixels per second in which the sprite will move/accelerate up * @param downSpeed The speed in pixels per second in which the sprite will move/accelerate down * @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally * @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically * @param xDeceleration Deceleration speed in pixels per second to apply to the sprites horizontal movement (default 0) * @param yDeceleration Deceleration speed in pixels per second to apply to the sprites vertical movement (default 0) */ public function setAdvancedMovementSpeed(leftSpeed:uint, rightSpeed:uint, upSpeed:uint, downSpeed:uint, xSpeedMax:uint, ySpeedMax:uint, xDeceleration:uint = 0, yDeceleration:uint = 0):void { leftMoveSpeed = -leftSpeed; rightMoveSpeed = rightSpeed; upMoveSpeed = -upSpeed; downMoveSpeed = downSpeed; setMaximumSpeed(xSpeedMax, ySpeedMax); setDeceleration(xDeceleration, yDeceleration); } /** * Set the speed at which the sprite will rotate when a direction key is pressed.
* Use this in combination with setMovementSpeed to create a Thrust like movement system.
* All values are given in pixels per second. So an xSpeed of 100 would rotate the sprite 100 pixels in 1 second (1000ms)
* Due to the nature of the internal Flash timer this amount is not 100% accurate and will vary above/below the desired distance by a few pixels.
*/ public function setRotationSpeed(antiClockwiseSpeed:Number, clockwiseSpeed:Number, speedMax:Number, deceleration:Number):void { antiClockwiseRotationSpeed = -antiClockwiseSpeed; clockwiseRotationSpeed = clockwiseSpeed; setRotationKeys(); setMaximumRotationSpeed(speedMax); setRotationDeceleration(deceleration); } /** * * * @param rotationType * @param stoppingType */ public function setRotationType(rotationType:int, stoppingType:int):void { rotation = rotationType; rotationStopping = stoppingType; } /** * Sets the maximum speed (in pixels per second) that the FlxSprite can rotate.
* When the FlxSprite is accelerating (movement type MOVEMENT_ACCELERATES) its speed won't increase above this value.
* However Flixel allows the velocity of an FlxSprite to be set to anything. So if you'd like to check the value and restrain it, then enable ""limitVelocity"". * * @param speed The maximum speed in pixels per second in which the sprite can rotate * @param limitVelocity If true the angular velocity of the FlxSprite will be checked and kept within the limit. If false it can be set to anything. */ public function setMaximumRotationSpeed(speed:Number, limitVelocity:Boolean = true):void { entity.maxAngular = speed; capAngularVelocity = limitVelocity; } /** * Deceleration is a speed (in pixels per second) that is applied to the sprite if stopping type is ""DECELERATES"" and if no rotation is taking place.
* The velocity of the sprite will be reduced until it reaches zero. * * @param speed The speed in pixels per second at which the sprite will have its angular rotation speed decreased */ public function setRotationDeceleration(speed:Number):void { entity.angularDrag = speed; } /** * Set minimum and maximum angle limits that the Sprite won't be able to rotate beyond.
* Values must be between -180 and +180. 0 is pointing right, 90 down, 180 left, -90 up. * * @param minimumAngle Minimum angle below which the sprite cannot rotate (must be -180 or above) * @param maximumAngle Maximum angle above which the sprite cannot rotate (must be 180 or below) */ public function setRotationLimits(minimumAngle:int, maximumAngle:int):void { if (minimumAngle > maximumAngle || minimumAngle < -180 || maximumAngle > 180) { throw new Error(""FlxControlHandler setRotationLimits: Invalid Minimum / Maximum angle""); } else { enforceAngleLimits = true; minAngle = minimumAngle; maxAngle = maximumAngle; } } /** * Disables rotation limits set in place by setRotationLimits() */ public function disableRotationLimits():void { enforceAngleLimits = false; } /** * Set which keys will rotate the sprite. The speed of rotation is set in setRotationSpeed. * * @param leftRight Use the LEFT and RIGHT arrow keys for anti-clockwise and clockwise rotation respectively. * @param upDown Use the UP and DOWN arrow keys for anti-clockwise and clockwise rotation respectively. * @param customAntiClockwise The String value of your own key to use for anti-clockwise rotation (as taken from org.flixel.system.input.Keyboard) * @param customClockwise The String value of your own key to use for clockwise rotation (as taken from org.flixel.system.input.Keyboard) */ public function setRotationKeys(leftRight:Boolean = true, upDown:Boolean = false, customAntiClockwise:String = """", customClockwise:String = """"):void { isRotating = true; rotateAntiClockwise = true; rotateClockwise = true; antiClockwiseKey = ""LEFT""; clockwiseKey = ""RIGHT""; if (upDown == true) { antiClockwiseKey = ""UP""; clockwiseKey = ""DOWN""; } if (customAntiClockwise != """" && customClockwise != """") { antiClockwiseKey = customAntiClockwise; clockwiseKey = customClockwise; } } /** * If you want to enable a Thrust like motion for your sprite use this to set the speed and keys.
* This is usually used in conjunction with Rotation and it will over-ride anything already defined in setMovementSpeed. * * @param thrustKey Specify the key String (as taken from org.flixel.system.input.Keyboard) to use for the Thrust action * @param thrustSpeed The speed in pixels per second which the sprite will move. Acceleration or Instant movement is determined by the Movement Type. * @param reverseKey If you want to be able to reverse, set the key string as taken from org.flixel.system.input.Keyboard (defaults to null). * @param reverseSpeed The speed in pixels per second which the sprite will reverse. Acceleration or Instant movement is determined by the Movement Type. */ public function setThrust(thrustKey:String, thrustSpeed:Number, reverseKey:String = null, reverseSpeed:Number = 0):void { thrustEnabled = false; reverseEnabled = false; if (thrustKey) { this.thrustKey = thrustKey; this.thrustSpeed = thrustSpeed; thrustEnabled = true; } if (reverseKey) { this.reverseKey = reverseKey; this.reverseSpeed = reverseSpeed; reverseEnabled = true; } } /** * Sets the maximum speed (in pixels per second) that the FlxSprite can move. You can set the horizontal and vertical speeds independantly.
* When the FlxSprite is accelerating (movement type MOVEMENT_ACCELERATES) its speed won't increase above this value.
* However Flixel allows the velocity of an FlxSprite to be set to anything. So if you'd like to check the value and restrain it, then enable ""limitVelocity"". * * @param xSpeed The maximum speed in pixels per second in which the sprite can move horizontally * @param ySpeed The maximum speed in pixels per second in which the sprite can move vertically * @param limitVelocity If true the velocity of the FlxSprite will be checked and kept within the limit. If false it can be set to anything. */ public function setMaximumSpeed(xSpeed:uint, ySpeed:uint, limitVelocity:Boolean = true):void { entity.maxVelocity.x = xSpeed; entity.maxVelocity.y = ySpeed; capVelocity = limitVelocity; } /** * Deceleration is a speed (in pixels per second) that is applied to the sprite if stopping type is ""DECELERATES"" and if no acceleration is taking place.
* The velocity of the sprite will be reduced until it reaches zero, and can be configured separately per axis. * * @param xSpeed The speed in pixels per second at which the sprite will have its horizontal speed decreased * @param ySpeed The speed in pixels per second at which the sprite will have its vertical speed decreased */ public function setDeceleration(xSpeed:uint, ySpeed:uint):void { entity.drag.x = xSpeed; entity.drag.y = ySpeed; } /** * Gravity can be applied to the sprite, pulling it in any direction.
* Gravity is given in pixels per second and is applied as acceleration. The speed the sprite reaches under gravity will never exceed the Maximum Movement Speeds set.
* If you don't want gravity for a specific direction pass a value of zero. * * @param xForce A positive value applies gravity dragging the sprite to the right. A negative value drags the sprite to the left. Zero disables horizontal gravity. * @param yForce A positive value applies gravity dragging the sprite down. A negative value drags the sprite up. Zero disables vertical gravity. */ public function setGravity(xForce:int, yForce:int):void { gravityX = xForce; gravityY = yForce; entity.acceleration.x = gravityX; entity.acceleration.y = gravityY; } /** * Switches the gravity applied to the sprite. If gravity was +400 Y (pulling them down) this will swap it to -400 Y (pulling them up)
* To reset call flipGravity again */ public function flipGravity():void { if (gravityX && gravityX != 0) { gravityX = -gravityX; entity.acceleration.x = gravityX; } if (gravityY && gravityY != 0) { gravityY = -gravityY; entity.acceleration.y = gravityY; } } /** * TODO * * @param xFactor * @param yFactor */ public function speedUp(xFactor:Number, yFactor:Number):void { } /** * TODO * * @param xFactor * @param yFactor */ public function slowDown(xFactor:Number, yFactor:Number):void { } /** * TODO * * @param xFactor * @param yFactor */ public function resetSpeeds(resetX:Boolean = true, resetY:Boolean = true):void { if (resetX) { xSpeedAdjust = 0; } if (resetY) { ySpeedAdjust = 0; } } /** * Creates a new Hot Key, which can be bound to any function you specify (such as ""swap weapon"", ""quit"", etc) * * @param key The key to use as the hot key (String from org.flixel.system.input.Keyboard, i.e. ""SPACE"", ""CONTROL"", ""Q"", etc) * @param callback The function to call when the key is pressed * @param keymode The keymode that will trigger the callback, either KEYMODE_PRESSED, KEYMODE_JUST_DOWN or KEYMODE_RELEASED */ public function addHotKey(key:String, callback:Function, keymode:int):void { } /** * Removes a previously defined hot key * * @param key The key to use as the hot key (String from org.flixel.system.input.Keyboard, i.e. ""SPACE"", ""CONTROL"", ""Q"", etc) * @return true if the key was found and removed, false if the key couldn't be found */ public function removeHotKey(key:String):Boolean { return true; } /** * Set sound effects for the movement events jumping, firing, walking and thrust. * * @param jump The FlxSound to play when the user jumps * @param fire The FlxSound to play when the user fires * @param walk The FlxSound to play when the user walks * @param thrust The FlxSound to play when the user thrusts */ public function setSounds(jump:FlxSound = null, fire:FlxSound = null, walk:FlxSound = null, thrust:FlxSound = null):void { if (jump) { jumpSound = jump; } if (fire) { fireSound = fire; } if (walk) { walkSound = walk; } if (thrust) { thrustSound = thrust; } } /** * Enable a fire button * * @param key The key to use as the fire button (String from org.flixel.system.input.Keyboard, i.e. ""SPACE"", ""CONTROL"") * @param keymode The FlxControlHandler KEYMODE value (KEYMODE_PRESSED, KEYMODE_JUST_DOWN, KEYMODE_RELEASED) * @param repeatDelay Time delay in ms between which the fire action can repeat (0 means instant, 250 would allow it to fire approx. 4 times per second) * @param callback A user defined function to call when it fires * @param altKey Specify an alternative fire key that works AS WELL AS the primary fire key (TODO) */ public function setFireButton(key:String, keymode:uint, repeatDelay:uint, callback:Function, altKey:String = """"):void { fireKey = key; fireKeyMode = keymode; fireRate = repeatDelay; fireCallback = callback; if (altKey != """") { altFireKey = altKey; } fire = true; } /** * Enable a jump button * * @param key The key to use as the jump button (String from org.flixel.system.input.Keyboard, i.e. ""SPACE"", ""CONTROL"") * @param keymode The FlxControlHandler KEYMODE value (KEYMODE_PRESSED, KEYMODE_JUST_DOWN, KEYMODE_RELEASED) * @param height The height in pixels/sec that the Sprite will attempt to jump (gravity and acceleration can influence this actual height obtained) * @param surface A bitwise combination of all valid surfaces the Sprite can jump off (from FlxObject, such as FlxObject.FLOOR) * @param repeatDelay Time delay in ms between which the jumping can repeat (250 would be 4 times per second) * @param jumpFromFall A time in ms that allows the Sprite to still jump even if it's just fallen off a platform, if still within ths time limit * @param callback A user defined function to call when the Sprite jumps * @param altKey Specify an alternative jump key that works AS WELL AS the primary jump key (TODO) */ public function setJumpButton(key:String, keymode:uint, height:int, surface:int, repeatDelay:uint = 250, jumpFromFall:int = 0, callback:Function = null, altKey:String = """"):void { jumpKey = key; jumpKeyMode = keymode; jumpHeight = height; jumpSurface = surface; jumpRate = repeatDelay; jumpFromFallTime = jumpFromFall; jumpCallback = callback; if (altKey != """") { altJumpKey = altKey; } jump = true; } /** * Limits the sprite to only be allowed within this rectangle. If its x/y coordinates go outside it will be repositioned back inside.
* Coordinates should be given in GAME WORLD pixel values (not screen value, although often they are the two same things) * * @param x The x coordinate of the top left corner of the area (in game world pixels) * @param y The y coordinate of the top left corner of the area (in game world pixels) * @param width The width of the area (in pixels) * @param height The height of the area (in pixels) */ public function setBounds(x:int, y:int, width:uint, height:uint):void { bounds = new Rectangle(x, y, width, height); } /** * Clears any previously set sprite bounds */ public function removeBounds():void { bounds = null; } private function moveUp():Boolean { var move:Boolean = false; if (FlxG.keys.pressed(upKey)) { move = true; isPressedUp = true; if (yFacing) { entity.facing = FlxObject.UP; } if (movement == MOVEMENT_INSTANT) { entity.velocity.y = upMoveSpeed; } else if (movement == MOVEMENT_ACCELERATES) { entity.acceleration.y = upMoveSpeed; } if (bounds && entity.y < bounds.top) { entity.y = bounds.top; } } return move; } private function moveDown():Boolean { var move:Boolean = false; if (FlxG.keys.pressed(downKey)) { move = true; isPressedDown = true; if (yFacing) { entity.facing = FlxObject.DOWN; } if (movement == MOVEMENT_INSTANT) { entity.velocity.y = downMoveSpeed; } else if (movement == MOVEMENT_ACCELERATES) { entity.acceleration.y = downMoveSpeed; } if (bounds && entity.y > bounds.bottom) { entity.y = bounds.bottom; } } return move; } private function moveLeft():Boolean { var move:Boolean = false; if (FlxG.keys.pressed(leftKey)) { move = true; isPressedLeft = true; if (xFacing) { entity.facing = FlxObject.LEFT; } if (movement == MOVEMENT_INSTANT) { entity.velocity.x = leftMoveSpeed; } else if (movement == MOVEMENT_ACCELERATES) { entity.acceleration.x = leftMoveSpeed; } if (bounds && entity.x < bounds.x) { entity.x = bounds.x; } } return move; } private function moveRight():Boolean { var move:Boolean = false; if (FlxG.keys.pressed(rightKey)) { move = true; isPressedRight = true; if (xFacing) { entity.facing = FlxObject.RIGHT; } if (movement == MOVEMENT_INSTANT) { entity.velocity.x = rightMoveSpeed; } else if (movement == MOVEMENT_ACCELERATES) { entity.acceleration.x = rightMoveSpeed; } if (bounds && entity.x > bounds.right) { entity.x = bounds.right; } } return move; } private function moveAntiClockwise():Boolean { var move:Boolean = false; if (FlxG.keys.pressed(antiClockwiseKey)) { move = true; if (rotation == ROTATION_INSTANT) { entity.angularVelocity = antiClockwiseRotationSpeed; } else if (rotation == ROTATION_ACCELERATES) { entity.angularAcceleration = antiClockwiseRotationSpeed; } // - Not quite there yet given the way Flixel can rotate to any valid int angle! if (enforceAngleLimits) { //entity.angle = FlxMath.angleLimit(entity.angle, minAngle, maxAngle); } } return move; } private function moveClockwise():Boolean { var move:Boolean = false; if (FlxG.keys.pressed(clockwiseKey)) { move = true; if (rotation == ROTATION_INSTANT) { entity.angularVelocity = clockwiseRotationSpeed; } else if (rotation == ROTATION_ACCELERATES) { entity.angularAcceleration = clockwiseRotationSpeed; } // - Not quite there yet given the way Flixel can rotate to any valid int angle! if (enforceAngleLimits) { //entity.angle = FlxMath.angleLimit(entity.angle, minAngle, maxAngle); } } return move; } private function moveThrust():Boolean { var move:Boolean = false; if (FlxG.keys.pressed(thrustKey)) { move = true; var motion:FlxPoint = FlxVelocity.velocityFromAngle(entity.angle, thrustSpeed); if (movement == MOVEMENT_INSTANT) { entity.velocity.x = motion.x; entity.velocity.y = motion.y; } else if (movement == MOVEMENT_ACCELERATES) { entity.acceleration.x = motion.x; entity.acceleration.y = motion.y; } if (bounds && entity.x < bounds.x) { entity.x = bounds.x; } } if (move && thrustSound) { thrustSound.play(false); } return move; } private function moveReverse():Boolean { var move:Boolean = false; if (FlxG.keys.pressed(reverseKey)) { move = true; var motion:FlxPoint = FlxVelocity.velocityFromAngle(entity.angle, reverseSpeed); if (movement == MOVEMENT_INSTANT) { entity.velocity.x = -motion.x; entity.velocity.y = -motion.y; } else if (movement == MOVEMENT_ACCELERATES) { entity.acceleration.x = -motion.x; entity.acceleration.y = -motion.y; } if (bounds && entity.x < bounds.x) { entity.x = bounds.x; } } return move; } private function runFire():Boolean { var fired:Boolean = false; // 0 = Pressed // 1 = Just Down // 2 = Just Released if ((fireKeyMode == 0 && FlxG.keys.pressed(fireKey)) || (fireKeyMode == 1 && FlxG.keys.justPressed(fireKey)) || (fireKeyMode == 2 && FlxG.keys.justReleased(fireKey))) { if (fireRate > 0) { if (getTimer() > nextFireTime) { lastFiredTime = getTimer(); fireCallback.call(); fired = true; nextFireTime = lastFiredTime + fireRate; } } else { lastFiredTime = getTimer(); fireCallback.call(); fired = true; } } if (fired && fireSound) { fireSound.play(true); } return fired; } private function runJump():Boolean { var jumped:Boolean = false; // This should be called regardless if they've pressed jump or not if (entity.isTouching(jumpSurface)) { extraSurfaceTime = getTimer() + jumpFromFallTime; } if ((jumpKeyMode == KEYMODE_PRESSED && FlxG.keys.pressed(jumpKey)) || (jumpKeyMode == KEYMODE_JUST_DOWN && FlxG.keys.justPressed(jumpKey)) || (jumpKeyMode == KEYMODE_RELEASED && FlxG.keys.justReleased(jumpKey))) { // Sprite not touching a valid jump surface if (entity.isTouching(jumpSurface) == false) { // They've run out of time to jump if (getTimer() > extraSurfaceTime) { return jumped; } else { // Still within the fall-jump window of time, but have jumped recently if (lastJumpTime > (extraSurfaceTime - jumpFromFallTime)) { return jumped; } } // If there is a jump repeat rate set and we're still less than it then return if (getTimer() < nextJumpTime) { return jumped; } } else { // If there is a jump repeat rate set and we're still less than it then return if (getTimer() < nextJumpTime) { return jumped; } } if (gravityY > 0) { // Gravity is pulling them down to earth, so they are jumping up (negative) entity.velocity.y = -jumpHeight; } else { // Gravity is pulling them up, so they are jumping down (positive) entity.velocity.y = jumpHeight; } if (jumpCallback is Function) { jumpCallback.call(); } lastJumpTime = getTimer(); nextJumpTime = lastJumpTime + jumpRate; jumped = true; } if (jumped && jumpSound) { jumpSound.play(true); } return jumped; } /** * Called by the FlxControl plugin */ public function update():void { if (entity == null) { return; } // Reset the helper booleans isPressedUp = false; isPressedDown = false; isPressedLeft = false; isPressedRight = false; if (stopping == STOPPING_INSTANT) { if (movement == MOVEMENT_INSTANT) { entity.velocity.x = 0; entity.velocity.y = 0; } else if (movement == MOVEMENT_ACCELERATES) { entity.acceleration.x = 0; entity.acceleration.y = 0; } } else if (stopping == STOPPING_DECELERATES) { if (movement == MOVEMENT_INSTANT) { entity.velocity.x = 0; entity.velocity.y = 0; } else if (movement == MOVEMENT_ACCELERATES) { // By default these are zero anyway, so it's safe to set like this entity.acceleration.x = gravityX; entity.acceleration.y = gravityY; } } // Rotation if (isRotating) { if (rotationStopping == ROTATION_STOPPING_INSTANT) { if (rotation == ROTATION_INSTANT) { entity.angularVelocity = 0; } else if (rotation == ROTATION_ACCELERATES) { entity.angularAcceleration = 0; } } else if (rotationStopping == ROTATION_STOPPING_DECELERATES) { if (rotation == ROTATION_INSTANT) { entity.angularVelocity = 0; } } var hasRotatedAntiClockwise:Boolean = false; var hasRotatedClockwise:Boolean = false; hasRotatedAntiClockwise = moveAntiClockwise(); if (hasRotatedAntiClockwise == false) { hasRotatedClockwise = moveClockwise(); } if (rotationStopping == ROTATION_STOPPING_DECELERATES) { if (rotation == ROTATION_ACCELERATES && hasRotatedAntiClockwise == false && hasRotatedClockwise == false) { entity.angularAcceleration = 0; } } // If they have got instant stopping with acceleration and are NOT pressing a key, then stop the rotation. Otherwise we let it carry on if (rotationStopping == ROTATION_STOPPING_INSTANT && rotation == ROTATION_ACCELERATES && hasRotatedAntiClockwise == false && hasRotatedClockwise == false) { entity.angularVelocity = 0; entity.angularAcceleration = 0; } } // Thrust if (thrustEnabled || reverseEnabled) { var moved:Boolean = false; if (thrustEnabled) { moved = moveThrust(); } if (moved == false && reverseEnabled) { moved = moveReverse(); } } else { var movedX:Boolean = false; var movedY:Boolean = false; if (up) { movedY = moveUp(); } if (down && movedY == false) { movedY = moveDown(); } if (left) { movedX = moveLeft(); } if (right && movedX == false) { movedX = moveRight(); } } if (fire) { runFire(); } if (jump) { runJump(); } if (capVelocity) { if (entity.velocity.x > entity.maxVelocity.x) { entity.velocity.x = entity.maxVelocity.x; } if (entity.velocity.y > entity.maxVelocity.y) { entity.velocity.y = entity.maxVelocity.y; } } if (walkSound) { if ((movement == MOVEMENT_INSTANT && entity.velocity.x != 0) || (movement == MOVEMENT_ACCELERATES && entity.acceleration.x != 0)) { walkSound.play(false); } else { walkSound.stop(); } } } /** * Sets Custom Key controls. Useful if none of the pre-defined sets work. All String values should be taken from org.flixel.system.input.Keyboard * Pass a blank (empty) String to disable that key from being checked. * * @param customUpKey The String to use for the Up key. * @param customDownKey The String to use for the Down key. * @param customLeftKey The String to use for the Left key. * @param customRightKey The String to use for the Right key. */ public function setCustomKeys(customUpKey:String, customDownKey:String, customLeftKey:String, customRightKey:String):void { if (customUpKey != """") { up = true; upKey = customUpKey; } if (customDownKey != """") { down = true; downKey = customDownKey; } if (customLeftKey != """") { left = true; leftKey = customLeftKey; } if (customRightKey != """") { right = true; rightKey = customRightKey; } } /** * Enables Cursor/Arrow Key controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.
* For example in a Space Invaders game you'd only enable LEFT and RIGHT. * * @param allowUp Enable the UP key * @param allowDown Enable the DOWN key * @param allowLeft Enable the LEFT key * @param allowRight Enable the RIGHT key */ public function setCursorControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void { up = allowUp; down = allowDown; left = allowLeft; right = allowRight; upKey = ""UP""; downKey = ""DOWN""; leftKey = ""LEFT""; rightKey = ""RIGHT""; } /** * Enables WASD controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.
* For example in a Space Invaders game you'd only enable LEFT and RIGHT. * * @param allowUp Enable the up (W) key * @param allowDown Enable the down (S) key * @param allowLeft Enable the left (A) key * @param allowRight Enable the right (D) key */ public function setWASDControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void { up = allowUp; down = allowDown; left = allowLeft; right = allowRight; upKey = ""W""; downKey = ""S""; leftKey = ""A""; rightKey = ""D""; } /** * Enables ESDF (home row) controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.
* For example in a Space Invaders game you'd only enable LEFT and RIGHT. * * @param allowUp Enable the up (E) key * @param allowDown Enable the down (D) key * @param allowLeft Enable the left (S) key * @param allowRight Enable the right (F) key */ public function setESDFControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void { up = allowUp; down = allowDown; left = allowLeft; right = allowRight; upKey = ""E""; downKey = ""D""; leftKey = ""S""; rightKey = ""F""; } /** * Enables IJKL (right-sided or secondary player) controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.
* For example in a Space Invaders game you'd only enable LEFT and RIGHT. * * @param allowUp Enable the up (I) key * @param allowDown Enable the down (K) key * @param allowLeft Enable the left (J) key * @param allowRight Enable the right (L) key */ public function setIJKLControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void { up = allowUp; down = allowDown; left = allowLeft; right = allowRight; upKey = ""I""; downKey = ""K""; leftKey = ""J""; rightKey = ""L""; } /** * Enables HJKL (Rogue / Net-Hack) controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.
* For example in a Space Invaders game you'd only enable LEFT and RIGHT. * * @param allowUp Enable the up (K) key * @param allowDown Enable the down (J) key * @param allowLeft Enable the left (H) key * @param allowRight Enable the right (L) key */ public function setHJKLControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void { up = allowUp; down = allowDown; left = allowLeft; right = allowRight; upKey = ""K""; downKey = ""J""; leftKey = ""H""; rightKey = ""L""; } /** * Enables ZQSD (Azerty keyboard) controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.
* For example in a Space Invaders game you'd only enable LEFT and RIGHT. * * @param allowUp Enable the up (Z) key * @param allowDown Enable the down (Q) key * @param allowLeft Enable the left (S) key * @param allowRight Enable the right (D) key */ public function setZQSDControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void { up = allowUp; down = allowDown; left = allowLeft; right = allowRight; upKey = ""Z""; downKey = ""S""; leftKey = ""Q""; rightKey = ""D""; } /** * Enables Dvoark Simplified Controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.
* For example in a Space Invaders game you'd only enable LEFT and RIGHT. * * @param allowUp Enable the up (COMMA) key * @param allowDown Enable the down (A) key * @param allowLeft Enable the left (O) key * @param allowRight Enable the right (E) key */ public function setDvorakSimplifiedControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void { up = allowUp; down = allowDown; left = allowLeft; right = allowRight; upKey = ""COMMA""; downKey = ""O""; leftKey = ""A""; rightKey = ""E""; } /** * Enables Numpad (left-handed) Controls. Can be set on a per-key basis. Useful if you only want to allow a few keys.
* For example in a Space Invaders game you'd only enable LEFT and RIGHT. * * @param allowUp Enable the up (NUMPADEIGHT) key * @param allowDown Enable the down (NUMPADTWO) key * @param allowLeft Enable the left (NUMPADFOUR) key * @param allowRight Enable the right (NUMPADSIX) key */ public function setNumpadControl(allowUp:Boolean = true, allowDown:Boolean = true, allowLeft:Boolean = true, allowRight:Boolean = true):void { up = allowUp; down = allowDown; left = allowLeft; right = allowRight; upKey = ""NUMPADEIGHT""; downKey = ""NUMPADTWO""; leftKey = ""NUMPADFOUR""; rightKey = ""NUMPADSIX""; } } }",12191,False,2434.1391032426054,median "/* * Copyright (C) 2003-2012 Igniterealtime Community Contributors * * Daniel Henninger * Derrick Grigg * Juga Paazmaya * Nick Velloff * Sean Treadway * Sean Voisen * Mark Walters * Michael McCarthy * * * Licensed under the Apache License, Version 2.0 (the ""License""); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an ""AS IS"" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.igniterealtime.xiff.conference { import org.igniterealtime.xiff.collections.ArrayCollection; import org.igniterealtime.xiff.core.EscapedJID; import org.igniterealtime.xiff.core.IXMPPConnection; import org.igniterealtime.xiff.core.UnescapedJID; import org.igniterealtime.xiff.data.IExtension; import org.igniterealtime.xiff.data.IMessage; import org.igniterealtime.xiff.data.IQ; import org.igniterealtime.xiff.data.Message; import org.igniterealtime.xiff.data.Presence; import org.igniterealtime.xiff.data.forms.FormExtension; import org.igniterealtime.xiff.data.forms.enum.FormType; import org.igniterealtime.xiff.data.muc.*; import org.igniterealtime.xiff.events.DisconnectionEvent; import org.igniterealtime.xiff.events.MessageEvent; import org.igniterealtime.xiff.events.PresenceEvent; import org.igniterealtime.xiff.events.PropertyChangeEvent; import org.igniterealtime.xiff.events.RoomEvent; /** * Dispatched when the active, affiliation, or role property changes. * * @eventType org.igniterealtime.xiff.events.PropertyChangeEvent.CHANGE */ [Event( name=""change"", type=""org.igniterealtime.xiff.events.PropertyChangeEvent"" )] /** * Dispatched when an administration action failed. * * @eventType org.igniterealtime.xiff.events.RoomEvent.ADMIN_ERROR * @see org.igniterealtime.xiff.core.XMPPConnection.error */ [Event( name=""adminError"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when an affiliation change has completed. * * @eventType org.igniterealtime.xiff.events.RoomEvent.AFFILIATION_CHANGE_COMPLETE */ [Event( name=""affiliationChangeComplete"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when an affiliation list has been requested. The event object contains an * array of MUCItems containing the JID and affiliation properties. * *

To grant or revoke permissions based on this list, only send the changes you wish to * make, calling grant/revoke with the new affiliation and existing JID.

* * @eventType org.igniterealtime.xiff.events.RoomEvent.AFFILIATIONS */ [Event( name=""affiliations"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched if the user attempted to join the room but was not allowed to do so because * they are banned (i.e., has an affiliation of ""outcast""). * * @eventType org.igniterealtime.xiff.events.RoomEvent.BANNED_ERROR */ [Event( name=""bannedError"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when a room configuration form is required. This can occur during the * creation of a room, or if a room configuration is requested. The RoomEvent * instance will contain an attribute data that is an instance of an object * with the following attributes: * *

instructions: Instructions for the use of form
* title: Title of the configuration form
* label: A friendly name for the field
* name: A computer readable identifier for the field used to identify * this field in the result passed to configure()
* type: The type of the field to be displayed. Type will be a constant * from the FormField class.

* * @see org.igniterealtime.xiff.data.forms.FormExtension * @see org.igniterealtime.xiff.data.forms.FormField * @see #configure * @eventType org.igniterealtime.xiff.events.RoomEvent.CONFIGURE_ROOM */ [Event( name=""configureRoom"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when a room configuration form is complete. * * @see #configure * @eventType org.igniterealtime.xiff.events.RoomEvent.CONFIGURE_ROOM_COMPLETE */ [Event(name=""configureRoomComplete"", type=""org.igniterealtime.xiff.events.RoomEvent"")] /** * Dispatched when an invite to this room has been declined by the invitee. The RoomEvent * data property that has the following attributes: * *

from: The JID of the user initiating the invite
* reason: A string containing the reason to join the room
* data: The original message containing the decline

* * @eventType org.igniterealtime.xiff.events.RoomEvent.DECLINED */ [Event( name=""declined"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched whenever a new message intented for all room occupants is received. The * RoomEvent class will contain an attribute data with the * group message as an instance of the Message class. * * @eventType org.igniterealtime.xiff.events.RoomEvent.GROUP_MESSAGE */ [Event( name=""groupMessage"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched if a user attempts to enter a room while it is ""locked"" (i.e., before the room * creator provides an initial configuration and therefore before the room officially exists). * * @eventType org.igniterealtime.xiff.events.RoomEvent.LOCKED_ERROR */ [Event( name=""lockedError"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched if the room has reached its maximum number of occupants. * * @eventType org.igniterealtime.xiff.events.RoomEvent.MAX_USERS_ERROR */ [Event( name=""maxUsersError"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when the user's preferred nickname already exists in the room. The * RoomEvent will contain an attribute nickname with the nickname * already existing in the room. * * @eventType org.igniterealtime.xiff.events.RoomEvent.NICK_CONFLICT */ [Event( name=""nickConflict"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when the room requires a password and the user did not supply one (or * the password provided is incorrect). * * @eventType org.igniterealtime.xiff.events.RoomEvent.PASSWORD_ERROR */ [Event( name=""passwordError"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched whenever a new private message is received. The RoomEvent class * contains an attribute data with the private message as an instance of the * Message class. * * @eventType org.igniterealtime.xiff.events.RoomEvent.PRIVATE_MESSAGE */ [Event( name=""privateMessage"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when the room is members-only and the user is not on the member list. * * @eventType org.igniterealtime.xiff.events.RoomEvent.REGISTRATION_REQ_ERROR */ [Event( name=""registrationReqError"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when the room is removed. * * @eventType org.igniterealtime.xiff.events.RoomEvent.ROOM_DESTROYED */ [Event( name=""roomDestroyed"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when you have entered the room and messages that are sent * will be displayed to other users. The room's role and affiliation will * be visible from this point forward. * * @eventType org.igniterealtime.xiff.events.RoomEvent.ROOM_JOIN */ [Event( name=""roomJoin"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when the server acknoledges that you have the left the room. * * @eventType org.igniterealtime.xiff.events.RoomEvent.ROOM_LEAVE */ [Event( name=""roomLeave"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when the room subject changes. * * @eventType org.igniterealtime.xiff.events.RoomEvent.SUBJECT_CHANGE */ [Event( name=""subjectChange"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when a user is banned from the room. * * @eventType org.igniterealtime.xiff.events.RoomEvent.USER_BANNED */ [Event( name=""userBanned"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched whenever an occpant leaves the room. The RoomEvent instance will * contain an attribute nickname with the nickname of the occupant who left. * * @eventType org.igniterealtime.xiff.events.RoomEvent.USER_DEPARTURE */ [Event( name=""userDeparture"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched whenever an occupant joins the room. The RoomEvent instance will * contain an attribute nickname with the nickname of the occupant who joined. * * @eventType org.igniterealtime.xiff.events.RoomEvent.USER_JOIN */ [Event( name=""userJoin"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when a user is kicked from the room. * * @eventType org.igniterealtime.xiff.events.RoomEvent.USER_KICKED */ [Event( name=""userKicked"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Dispatched when a user's presence changes. * * @eventType org.igniterealtime.xiff.events.RoomEvent.USER_PRESENCE_CHANGE */ [Event( name=""userPresenceChange"", type=""org.igniterealtime.xiff.events.RoomEvent"" )] /** * Manages incoming and outgoing data from a conference room as part of multi-user conferencing (XEP-0045). * You will need an instance of this class for each room that the user joins. * * @see http://xmpp.org/extensions/xep-0045.html */ public class Room extends ArrayCollection implements IRoom { public static const AFFILIATION_ADMIN:String = MUC.AFFILIATION_ADMIN; public static const AFFILIATION_MEMBER:String = MUC.AFFILIATION_MEMBER; public static const AFFILIATION_NONE:String = MUC.AFFILIATION_NONE; public static const AFFILIATION_OUTCAST:String = MUC.AFFILIATION_OUTCAST; public static const AFFILIATION_OWNER:String = MUC.AFFILIATION_OWNER; public static const ROLE_MODERATOR:String = MUC.ROLE_MODERATOR; public static const ROLE_NONE:String = MUC.ROLE_NONE; public static const ROLE_PARTICIPANT:String = MUC.ROLE_PARTICIPANT; public static const ROLE_VISITOR:String = MUC.ROLE_VISITOR; private var _active:Boolean; private var _affiliation:String; private var _anonymous:Boolean = true; private var _connection:IXMPPConnection; private var _nickname:String; private var _password:String; private var _role:String; private var _roomJID:UnescapedJID; private var _subject:String; private var _isReserved:Boolean; // Used to store nicknames in pending status, awaiting change approval from server private var _pendingNickname:String; private var _affiliationExtension:MUCBaseExtension; // TODO: How about using Interface here? private var _affiliationArgs:Array = []; /** * * @param aConnection A XMPPConnection instance that is providing the primary server connection */ public function Room( aConnection:IXMPPConnection = null ) { setActive(false); if ( aConnection != null ) { connection = aConnection; } _affiliationExtension = new MUCAdminExtension(); } /** * Allow a previously banned JIDs to enter this room. This is the same as: * Room.grant(AFFILIATION_NONE, jid) * *

If the process could not be completed, the room will dispatch the event * RoomEvent.ADMIN_ERROR

* * @param jids An array of unescaped JIDs to allow * @see #grant * @see #revoke */ public function allow( jids:Array ):void { grant( Room.AFFILIATION_NONE, jids ); } /** * Bans an array of JIDs from entering the room. * *

If the process could not be completed, the room will dispatch the event * RoomEvent.ADMIN_ERROR.

* * @param jids An arry of unescaped JIDs to ban */ public function ban( jids:Array ):void { var iq:IQ = new IQ( roomJID.escaped, IQ.TYPE_SET, null, ban_response, ban_error ); var adminExt:MUCAdminExtension = new MUCAdminExtension(); for each ( var banJID:UnescapedJID in jids ) { adminExt.addItem( Room.AFFILIATION_OUTCAST, null, null, banJID.escaped, null, null ); } iq.addExtension( adminExt ); _connection.send( iq ); } /** * Cancels the configuration process. The room may still be locked if * you cancel the configuration process when attempting to join a * reserved room. * *

You must have joined the room and have the owner affiliation to * configure the room.

* * @see #configureRoom * @see #configure * @see #join */ public function cancelConfiguration():void { var iq:IQ = new IQ( roomJID.escaped, IQ.TYPE_SET ); var ownerExt:MUCOwnerExtension = new MUCOwnerExtension(); var form:FormExtension = new FormExtension(); form.type = FormType.CANCEL; ownerExt.addExtension( form ); iq.addExtension( ownerExt ); _connection.send( iq ); } /** * Changes the subject in the conference room. You must have already joined the * room before you can change the subject. * * @param newSubject The new subject */ public function changeSubject( newSubject:String ):void { if ( active ) { var message:Message = new Message( roomJID.escaped, null, null, null, Message.TYPE_GROUPCHAT, newSubject ); _connection.send( message ); } } /** * Sends a configuration form to the room. * * You must be joined and have owner affiliation to configure the room * * @param fieldmap FormExtension, or a hash that is an object with keys being the room configuration * form variables and the values being arrays. For single value fields, use a single * element array. * @see #configureRoom * @see http://xmpp.org/extensions/xep-0045.html#registrar-formtype-owner */ public function configure( fieldmap:Object ):void { var iq:IQ = new IQ( roomJID.escaped, IQ.TYPE_SET, null, configure_response, configure_error ); var ownerExt:MUCOwnerExtension = new MUCOwnerExtension(); var form:FormExtension; if ( fieldmap is FormExtension ) { form = FormExtension( fieldmap ); } else { form = new FormExtension(); fieldmap[ ""FORM_TYPE"" ] = [ ""http://jabber.org/protocol/muc#roomconfig"" ]; form.setFieldMap( fieldmap ); } form.type = FormType.SUBMIT; ownerExt.addExtension( form ); iq.addExtension( ownerExt ); _connection.send( iq ); } /** * Actively decline an invitation. You can optionally ignore invitations * but if you choose to decline an invitation, you call this method on * a room instance that represents the room the invite originated from. * *

You do not need to have joined this room to decline an invitation

* *

Note: mu-conference-0.6 does not allow users to send decline * messages without joining first. If using this version of conferencing * software, it is best to ignore invites.

* * @param jid An unescaped JID of the user to invite. * @param reason A string describing why the invitiation was declined */ public function decline( jid:UnescapedJID, reason:String ):void { var message:Message = new Message( roomJID.escaped ); var userExt:MUCUserExtension = new MUCUserExtension(); userExt.decline( jid.escaped, undefined, reason ); message.addExtension( userExt ); _connection.send( message ); } /** * Destroys a reserved room. If the room has been configured to be persistent, * then it is optional that the server will permanently remove the room. * * @param reason A short description of why the room is being destroyed * @param alternateJID A JID for current members to use as an alternate room to join * after the room has been destroyed. Like a postal forwarding address. */ public function destroy( reason:String, alternateJID:UnescapedJID = null, callback:Function = null ):void { var iq:IQ = new IQ( roomJID.escaped, IQ.TYPE_SET ); var ownerExt:MUCOwnerExtension = new MUCOwnerExtension(); var jid:EscapedJID; if (alternateJID != null) { jid = alternateJID.escaped; } iq.callback = callback; ownerExt.destroy( reason, jid ); iq.addExtension( ownerExt ); _connection.send( iq ); } /** * Gets an instance of the Message class that has been pre-configured to be * sent from this room. Use this method to get a Message in order to add extensions * to outgoing room messages. * * @param body The message body * @param htmlBody The message body with HTML formatting * @return A Message class instance */ public function getMessage( body:String = null, htmlBody:String = null ):IMessage { var message:Message = new Message( roomJID.escaped, null, body, htmlBody, Message.TYPE_GROUPCHAT ); return message; } /** * Gets the RoomOccupant whose nickname matches the name passed in. * * @param name * @return */ public function getOccupantNamed( name:String ):IRoomOccupant { for each ( var occ:RoomOccupant in this ) { if ( occ.nickname == name ) { return occ; } } return null; } /** * Grants permissions on a room to one or more JIDs by setting the * affiliation of a user based on their JID. * *

If the JID currently has an existing affiliation, then the existing * affiliation will be replaced with the one passed. If the process could not be * completed, the room will dispatch the event RoomEvent.ADMIN_ERROR.

* *

XMPP spec states that the #admin schema should be used for affiliation changes. * Unfortunately to this date, Openfire does not match spec and requires the #owner schema. * Because of this, if granting privileges fails on the first attempt using the #admin schema, * we try again using the #owner schema.

* * @param affiliation Use one of the * following affiliations: Room.AFFILIATION_MEMBER, * Room.AFFILIATION_ADMIN, * Room.AFFILIATION_OWNER * @param jids An array of UnescapedJIDs to grant these permissions to * @see #revoke * @see #allow * @see http://xmpp.org/extensions/xep-0045.html#schemas-admin */ public function grant( affiliation:String, jids:Array ):void { _affiliationArgs = arguments; var iq:IQ = new IQ( roomJID.escaped, IQ.TYPE_SET, null, grant_response, grant_error ); for each ( var jid:UnescapedJID in jids ) { _affiliationExtension.addItem( affiliation, null, null, jid.escaped, null, null ); } iq.addExtension( _affiliationExtension as IExtension ); _connection.send( iq ); } /** * Invites a user that is not currently a member of this room to this room. * *

You must have joined the room and have appropriate permissions to invite * other memebers, because the server will format and send the invite message to * as if it came from the room rather that you sending the invite directly from you.

* *

To listen to invite events, add an event listener on your XMPPConnection to the * InviteEvent.INVITED event.

* * @param jid An unescaped JID of the user to invite. * @param reason A string describing why you would like to invite the user. */ public function invite( jid:UnescapedJID, reason:String ):void { var message:Message = new Message( roomJID.escaped ); var userExt:MUCUserExtension = new MUCUserExtension(); userExt.invite( jid.escaped, undefined, reason ); message.addExtension( userExt ); _connection.send( message ); } /** * Determines if the sender parameter is the same * as the room's JID. * * @param the room JID to test * @return true if the passed JID matches the getRoomJID */ public function isThisRoom( sender:UnescapedJID ):Boolean { return _roomJID ? sender.bareJID.toLowerCase() == _roomJID.bareJID.toLowerCase() : false; } /** * Determines if the sender param is the * same as the user's JID. * * @param sender the room JID to test * @return true if the passed JID matches the userJID */ public function isThisUser( sender:UnescapedJID ):Boolean { var value:Boolean = false; if (userJID != null) { value = sender.toString().toLowerCase() == userJID.toString().toLowerCase(); } return value; } /** * Joins a conference room based on the parameters specified by the room * properties. This call will create an instant room based on a default * server configuration if the room doesn't exist. * *

To create and begin the configuration process of a reserved room, pass * true to this method to begin the configuration process. When * The configuration is complete, the room will be unlocked for others to join. * Listen for the RoomEvent.CONFIGURE_ROOM event to handle and * either return or cancel the configuration of the room.

* * @param createReserved Set to true if you wish to create and configure a reserved room * @param joinPresenceExtensions An array of additional extensions to send with the initial presence to the room. * @return A boolean indicating whether the join attempt was successfully sent. */ public function join( createReserved:Boolean = false, joinPresenceExtensions:Array = null ):Boolean { var muc:MUCExtension = new MUCExtension(); if ( password != null ) { muc.password = password; } return joinWithExplicitMUCExtension(createReserved, muc, joinPresenceExtensions); } /** * Joins a conference room based on the parameters specified by the room * properties. This call will create an instant room based on a default * server configuration if the room doesn't exist. * *

To create and begin the configuration process of a reserved room, pass * true to this method to begin the configuration process. When * The configuration is complete, the room will be unlocked for others to join. * Listen for the RoomEvent.CONFIGURE_ROOM event to handle and * either return or cancel the configuration of the room.

* *

This function adds an additional parameter to allow the caller to completely customize the MUC extension that * gets sent to the room. For example, you can add a history element that specifies how much discussion * history you want sent when you join the room (http://xmpp.org/extensions/xep-0045.html#enter-managehistory): * * var muc:MUCExtension = new MUCExtension(); * muc.history = true; * muc.maxchars = 0; * _room.joinWithExplicitMUCExtension(false, mucExt); * *

* * @param createReserved Set to true if you wish to create and configure a reserved room * @param mucExtension The customized MUC extension to send with initial presence to the room. * @param joinPresenceExtensions An array of additional extensions to send with the initial presence to the room. * @return A boolean indicating whether the join attempt was successfully sent. */ public function joinWithExplicitMUCExtension( createReserved:Boolean, mucExtension:IMUCExtension, joinPresenceExtensions:Array = null ):Boolean { if ( !_connection.active || active ) { return false; } _isReserved = createReserved; var joinPresence:Presence = new Presence( userJID.escaped ); joinPresence.addExtension( mucExtension ); if ( joinPresenceExtensions != null ) { for each ( var joinExt:IExtension in joinPresenceExtensions ) { joinPresence.addExtension( joinExt ); } } _connection.send( joinPresence ); return true; } /** * Kicks an occupant out of the room, assuming that the user has necessary * permissions in order to do so. If the user does not, the server will return an error. * * @param occupantNick The nickname of the room occupant to kick * @param reason The reason for the kick */ public function kickOccupant( occupantNick:String, reason:String ):void { if ( active ) { var iq:IQ = new IQ( roomJID.escaped, IQ.TYPE_SET, IQ.generateID( ""kick_occupant_"" ) ); var adminExt:MUCAdminExtension = new MUCAdminExtension( iq.xml ); adminExt.addItem( null, MUC.ROLE_NONE, occupantNick, null, null, reason ); iq.addExtension( adminExt ); _connection.send( iq ); } } /** * Leaves the current conference room, assuming that the user has joined one. * If the user is not currently in a room, this method does nothing. */ public function leave():void { if ( active ) { var leavePresence:Presence = new Presence( userJID.escaped, null, Presence.TYPE_UNAVAILABLE ); _connection.send( leavePresence ); // Clear out the roster items removeAll(); _connection.removeEventListener( MessageEvent.MESSAGE, handleEvent ); _connection.removeEventListener( DisconnectionEvent.DISCONNECT, handleEvent ); } } /** * Requests an affiliation list for a given affiliation with with room. * This will either dispatch the event RoomEvent.AFFILIATIONS or * RoomEvent.ADMIN_ERROR depending on the result of the request. * * @param affiliation Use one of the following affiliations: Room.AFFILIATION_NONE, * Room.AFFILIATION_OUTCAST, * Room.AFFILIATION_MEMBER, * Room.AFFILIATION_ADMIN, * Room.AFFILIATION_OWNER * @see #revoke * @see #grant * @see #affiliations */ public function requestAffiliations( affiliation:String ):void { var iq:IQ = new IQ( roomJID.escaped, IQ.TYPE_GET, null, requestAffiliations_response, requestAffiliations_error ); var adminExt:MUCAdminExtension = new MUCAdminExtension(); adminExt.addItem( affiliation ); iq.addExtension( adminExt ); _connection.send( iq ); } /** * Requests a configuration form from the room. Listen to configureRoom * event to fill out the form then call either configure or * cancelConfiguration to complete the configuration process * * You must be joined to the room and have the owner affiliation to request * a configuration form * * @see #configureRoom * @see #configure * @see #cancelConfiguration */ public function requestConfiguration():void { var iq:IQ = new IQ( roomJID.escaped, IQ.TYPE_GET, null, requestConfiguration_response, requestConfiguration_error ); var ownerExt:MUCOwnerExtension = new MUCOwnerExtension(); iq.addExtension( ownerExt ); _connection.send( iq ); } /** * Revokes all affiliations from the JIDs. This is the same as: * grant( Room.AFFILIATION_NONE, jids ) * *

If the process could not be completed, the room will dispatch the event * RoomEvent.ADMIN_ERROR. Note: if the JID is banned from this room, * then this will also revoke the banned status.

* * @param jids An array of UnescapedJIDs to revoke affiliations from * @see #grant * @see #allow */ public function revoke( jids:Array ):void { grant( Room.AFFILIATION_NONE, jids ); } /** * Sends a message to the conference room. * * @param body The message body * @param htmlBody The message body with HTML formatting */ public function sendMessage( body:String = null, htmlBody:String = null ):void { if ( active ) { var message:Message = new Message( roomJID.escaped, null, body, htmlBody, Message.TYPE_GROUPCHAT ); _connection.send( message ); } } /** * Sends a message to the conference room with an extension attached. * Use this method in conjunction with the getMessage method. * * @param message The message to send */ public function sendMessageWithExtension( message:IMessage ):void { if ( active ) { _connection.send( message ); } } /** * Sends a private message to a specific participant in the conference room. * * @param recipientNickname The conference room nickname of the recipient who should * receive the private message * @param body The message body * @param htmlBody The message body with HTML formatting */ public function sendPrivateMessage( recipientNickname:String, body:String = null, htmlBody:String = null ):void { if ( active ) { var message:Message = new Message( new EscapedJID( roomJID + ""/"" + recipientNickname ), null, body, htmlBody, Message.TYPE_CHAT ); _connection.send( message ); } } /** * In a moderated room, sets voice status to a particular occupant, assuming the user * has the necessary permissions to do so. * * @param occupantNick The nickname of the occupant to give voice * @param voice Whether to add voice (true) or remove voice (false). Having voice means * that the user is actually able to talk. Without voice the user is effectively muted. */ public function setOccupantVoice( occupantNick:String, voice:Boolean ):void { if ( active ) { var iq:IQ = new IQ( roomJID.escaped, IQ.TYPE_SET, IQ.generateID( ""voice_"" ) ); var adminExt:MUCAdminExtension = new MUCAdminExtension( iq.xml ); adminExt.addItem( null, voice ? MUC.ROLE_PARTICIPANT : MUC.ROLE_VISITOR, occupantNick ); iq.addExtension( adminExt ); _connection.send( iq ); } } /** * @private */ override public function toString():String { return '[object Room]'; } /** * @private * * The default error handler for admin IQ messages. * Dispatches the adminError event. */ private function admin_error( iq:IQ ):void { var event:RoomEvent = new RoomEvent( RoomEvent.ADMIN_ERROR ); event.errorCondition = iq.errorCondition; event.errorMessage = iq.errorMessage; event.errorType = iq.errorType; event.errorCode = iq.errorCode; dispatchEvent( event ); } /** * @private * * The default response handler for admin IQ messages. */ private function admin_response( iq:IQ ):void { } /** * @private */ private function ban_error( iq:IQ ):void { admin_error( iq ); } /** * @private */ private function ban_response( iq:IQ ):void { } /** * @private */ private function configure_error( iq:IQ ):void { admin_error( iq ); } /** * @private */ private function configure_response( iq:IQ ):void { var event:RoomEvent = new RoomEvent( RoomEvent.CONFIGURE_ROOM_COMPLETE ); dispatchEvent( event ); } /** * Helper to dispatch a property change event. * @param name * @param newValue * @param oldValue */ private function dispatchChangeEvent( name:String, newValue:*, oldValue:* ):void { var event:PropertyChangeEvent = new PropertyChangeEvent( PropertyChangeEvent.CHANGE ); event.name = name; event.newValue = newValue; event.oldValue = oldValue; dispatchEvent( event ); } /** * @private */ private function grant_error( iq:IQ ):void { if ( _affiliationExtension is MUCAdminExtension && _affiliationArgs.length > 0 ) { _affiliationExtension = new MUCOwnerExtension(); grant.apply( null, _affiliationArgs ); } else { _affiliationArgs = []; admin_error( iq ); } } /** * @private */ private function grant_response( iq:IQ ):void { _affiliationArgs = []; var event:RoomEvent = new RoomEvent( RoomEvent.AFFILIATION_CHANGE_COMPLETE ); dispatchEvent( event ); } /** * @private * * @param eventObj */ private function handleEvent( eventObj:Object ):void { var userExt:MUCUserExtension; switch ( eventObj.type ) { case ""message"": var message:Message = eventObj.data; var userExts:Array = message.getAllExtensionsByNS( MUCUserExtension.NS ); var roomEvent:RoomEvent; // Check to see that the message is from this room if ( isThisRoom( message.from.unescaped )) { if ( message.type == Message.TYPE_GROUPCHAT ) { // Check for a subject change if ( message.subject != null ) { _subject = message.subject; roomEvent = new RoomEvent( RoomEvent.SUBJECT_CHANGE ); roomEvent.subject = message.subject; dispatchEvent( roomEvent ); } else { //silently ignore ""room is not anonymous"" message, identified by status code 100 //Clients should display that information in their UI based on the appropriate room property if ( !userExts || userExts.length == 0 || !( userExts[ 0 ].hasStatusCode( 100 ))) { roomEvent = new RoomEvent( RoomEvent.GROUP_MESSAGE ); roomEvent.nickname = message.from.resource; roomEvent.data = message; dispatchEvent( roomEvent ); } } } else if ( message.type == Message.TYPE_NORMAL ) { var form:Array = message.getAllExtensionsByNS( FormExtension.NS )[ 0 ]; if ( form ) { roomEvent = new RoomEvent( RoomEvent.CONFIGURE_ROOM ); roomEvent.data = form; dispatchEvent( roomEvent ); } } else if ( message.type == Message.TYPE_CHAT ) { roomEvent = new RoomEvent( RoomEvent.PRIVATE_MESSAGE ); roomEvent.nickname = message.from.resource; roomEvent.data = message; dispatchEvent( roomEvent ); } } else if ( isThisUser( message.to.unescaped ) && message.type == Message.TYPE_CHAT ) { // It could be a private message via the conference roomEvent = new RoomEvent( RoomEvent.PRIVATE_MESSAGE ); roomEvent.data = message; dispatchEvent( roomEvent ); } else { // Could be a decline to a previous invite if ( userExts != null && userExts.length > 0 ) { userExt = userExts[ 0 ]; if ( userExt && userExt.type == MUCUserExtension.TYPE_DECLINE ) { roomEvent = new RoomEvent( RoomEvent.DECLINED ); roomEvent.from = userExt.reason; roomEvent.reason = userExt.reason; roomEvent.data = message; dispatchEvent( roomEvent ); } } } break; case ""presence"": for each ( var presence:Presence in eventObj.data ) { if ( presence.type == Presence.TYPE_ERROR ) { switch ( presence.errorCode ) { case 401: roomEvent = new RoomEvent( RoomEvent.PASSWORD_ERROR ); break; case 403: roomEvent = new RoomEvent( RoomEvent.BANNED_ERROR ); break; case 404: roomEvent = new RoomEvent( RoomEvent.LOCKED_ERROR ); break; case 407: roomEvent = new RoomEvent( RoomEvent.REGISTRATION_REQ_ERROR ); break; case 409: roomEvent = new RoomEvent( RoomEvent.NICK_CONFLICT ); roomEvent.nickname = nickname; break; case 503: roomEvent = new RoomEvent( RoomEvent.MAX_USERS_ERROR ); break; default: roomEvent = new RoomEvent( ""MUC Error of type: "" + presence.errorCode ); break; } roomEvent.errorCode = presence.errorCode; roomEvent.errorMessage = presence.errorMessage; dispatchEvent( roomEvent ); } else if ( isThisRoom( presence.from.unescaped )) { // If the presence has our pending nickname, nickname change went through if ( presence.from.resource == _pendingNickname ) { _nickname = _pendingNickname; _pendingNickname = null; } userExt = presence.getAllExtensionsByNS( MUCUserExtension.NS )[ 0 ]; for each ( var status:MUCStatus in userExt.statuses ) { switch ( status.code ) { case 100: case 172: _anonymous = false; break; case 174: _anonymous = true; break; case 201: unlockRoom( _isReserved ); break; } } updateRoomRoster( presence ); if ( presence.type == Presence.TYPE_UNAVAILABLE && active && isThisUser( presence.from.unescaped )) { setActive(false); if ( userExt.type == MUCUserExtension.TYPE_DESTROY ) { roomEvent = new RoomEvent( RoomEvent.ROOM_DESTROYED ); } else { roomEvent = new RoomEvent( RoomEvent.ROOM_LEAVE ); } dispatchEvent( roomEvent ); _connection.removeEventListener( PresenceEvent.PRESENCE, handleEvent ); } } } break; case ""disconnection"": // The server disconnected, so we are no longer active setActive(false); removeAll(); roomEvent = new RoomEvent( RoomEvent.ROOM_LEAVE ); dispatchEvent( roomEvent ); break; } } /** * @private */ private function requestAffiliations_error( iq:IQ ):void { admin_error( iq ); } /** * @private */ private function requestAffiliations_response( iq:IQ ):void { if ( iq.type == IQ.TYPE_RESULT ) { var adminExt:MUCAdminExtension = iq.getAllExtensionsByNS( MUCAdminExtension.NS )[ 0 ]; var event:RoomEvent = new RoomEvent( RoomEvent.AFFILIATIONS ); event.data = adminExt.items; dispatchEvent( event ); } } /** * @private */ private function requestConfiguration_error( iq:IQ ):void { admin_error( iq ); } /** * @private */ private function requestConfiguration_response( iq:IQ ):void { var ownerExt:MUCOwnerExtension = iq.getAllExtensionsByNS( MUCOwnerExtension.NS )[ 0 ]; var form:FormExtension = ownerExt.getAllExtensionsByNS( FormExtension.NS )[ 0 ]; if ( form.type == FormType.FORM ) { var event:RoomEvent = new RoomEvent( RoomEvent.CONFIGURE_ROOM ); event.data = form; dispatchEvent( event ); } } /** * @private * * Room owner (creation/configuration/destruction) methods * @see http://xmpp.org/extensions/xep-0045.html#createroom */ private function unlockRoom( isReserved:Boolean ):void { if ( isReserved ) { requestConfiguration(); } else { // Send an empty configuration form to open the instant room // The IQ.result for this request will signify that the room is // unlocked. Sometimes there are messages that are sent before // the request is returned. It may be smart to either block those // messages, or provide 2 events ""beginConfiguration"" and ""endConfiguration"" // so the application can decide to block configuration messages var iq:IQ = new IQ( roomJID.escaped, IQ.TYPE_SET ); var ownerExt:MUCOwnerExtension = new MUCOwnerExtension(); var form:FormExtension = new FormExtension(); form.type = FormType.SUBMIT; ownerExt.addExtension( form ); iq.addExtension( ownerExt ); _connection.send( iq ); } } /** * @private * * If we receive a presence about ourselves, it means * a) we've joined the room; tell everyone, then proceed as usual * b) we're being told we left, which we handle in the caller * @param aPresence */ private function updateRoomRoster( aPresence:Presence ):void { var userNickname:String = aPresence.from.unescaped.resource; var userExts:Array = aPresence.getAllExtensionsByNS( MUCUserExtension.NS ); var item:MUCItem = userExts[ 0 ].items[ 0 ]; var roomEvent:RoomEvent; if ( isThisUser( aPresence.from.unescaped )) { if ( _affiliation != item.affiliation ) { dispatchChangeEvent( ""affiliation"",item.affiliation, _affiliation ); } _affiliation = item.affiliation; if ( _role != item.role ) { dispatchChangeEvent( ""role"", item.role, _role ); } _role = item.role; if ( !active && aPresence.type != Presence.TYPE_UNAVAILABLE ) { setActive(true); roomEvent = new RoomEvent( RoomEvent.ROOM_JOIN ); dispatchEvent( roomEvent ); } } var occupant:IRoomOccupant = getOccupantNamed( userNickname ); //if we already know about this occupant, we're either being told about them leaving, or about a presence update if ( occupant ) { if ( aPresence.type == Presence.TYPE_UNAVAILABLE ) { removeItemAt( getItemIndex( occupant )); var userExt:MUCUserExtension = aPresence.getAllExtensionsByNS( MUCUserExtension.NS )[ 0 ]; for each ( var status:MUCStatus in userExt.statuses ) { switch ( status.code ) { // If the user left as a result of a ban or kick, we dispatch a USER_BANNED/USER_KICKED event instead of a USER_DEPARTURE event case 301: roomEvent = new RoomEvent( RoomEvent.USER_BANNED ); roomEvent.nickname = userNickname; roomEvent.data = aPresence; dispatchEvent( roomEvent ); return; case 307: roomEvent = new RoomEvent( RoomEvent.USER_KICKED ); roomEvent.nickname = userNickname; roomEvent.data = aPresence; dispatchEvent( roomEvent ); return; } } // Notify listeners that a user has left the room roomEvent = new RoomEvent( RoomEvent.USER_DEPARTURE ); roomEvent.nickname = userNickname; roomEvent.data = aPresence; dispatchEvent( roomEvent ); } else { occupant.affiliation = item.affiliation; occupant.role = item.role; occupant.show = aPresence.show; // Notify listeners that a user's presence has been updated roomEvent = new RoomEvent( RoomEvent.USER_PRESENCE_CHANGE ); roomEvent.nickname = userNickname; roomEvent.data = aPresence; dispatchEvent( roomEvent ); } } else if ( aPresence.type != Presence.TYPE_UNAVAILABLE ) { // We didn't know about this occupant yet, so we add them, then let everyone know that we did. addItem( new RoomOccupant( userNickname, aPresence.show, item.affiliation, item.role, item.jid ? item.jid.unescaped : null, this )); roomEvent = new RoomEvent( RoomEvent.USER_JOIN ); roomEvent.nickname = userNickname; roomEvent.data = aPresence; dispatchEvent( roomEvent ); } } /** * Gets the user's affiliation for this room. * Possible affiliations are ""owner"", ""admin"", ""member"", and ""outcast"". * It is also possible to have no defined affiliation. */ public function get affiliation():String { return _affiliation; } /** * Whether the room shows full JIDs or not. */ public function get anonymous():Boolean { return _anonymous; } /** * A reference to the XMPPConnection being used for incoming/outgoing XMPP data. * * @see org.igniterealtime.xiff.core.XMPPConnection */ public function get connection():IXMPPConnection { return _connection; } public function set connection( value:IXMPPConnection ):void { if ( _connection != null ) { _connection.removeEventListener( MessageEvent.MESSAGE, handleEvent ); _connection.removeEventListener( PresenceEvent.PRESENCE, handleEvent ); _connection.removeEventListener( DisconnectionEvent.DISCONNECT, handleEvent ); } _connection = value; _connection.addEventListener( MessageEvent.MESSAGE, handleEvent, false, 0, true ); _connection.addEventListener( PresenceEvent.PRESENCE, handleEvent, false, 0, true ); _connection.addEventListener( DisconnectionEvent.DISCONNECT, handleEvent, false, 0, true ); _connection.enableExtensions( FormExtension, MUCExtension, MUCUserExtension, MUCOwnerExtension, MUCAdminExtension ); } /** * The conference server to use for this room. Usually, this is a subdomain of * the primary XMPP server, like conference.myserver.com. */ public function get conferenceServer():String { return _roomJID ? _roomJID.domain : null; } public function set conferenceServer( value:String ):void { roomJID = new UnescapedJID( roomName + ""@"" + value ); } /** * Determines whether the connection to the room is active - that is, the user * is connected and has joined the room. */ public function get active():Boolean { return _active; } /** * Needs to be available only within this class * * @param state */ private function setActive( state:Boolean ):void { if ( _active != state ) { dispatchChangeEvent( ""active"", state, _active ); } _active = state; } /** * The nickname to use when joining. */ public function get nickname():String { return _nickname == null ? _connection.username : _nickname; } public function set nickname( value:String ):void { if ( active ) { _pendingNickname = value; var presence:Presence = new Presence( new EscapedJID( userJID + ""/"" + value ) ); _connection.send( presence ); } else { _nickname = value; } } /** * The password. */ public function get password():String { return _password; } public function set password( value:String ):void { _password = value; } /** * Gets the user's role in the conference room. * *

Possible roles are ""visitor"", ""participant"", ""moderator"" or no defined role.

*
    *
  • ROLE_MODERATOR
  • *
  • ROLE_NONE
  • *
  • ROLE_PARTICIPANT
  • *
  • ROLE_VISITOR
  • *
*/ public function get role():String { return _role; } /** * The unescaped JID of the room. room@conference.server * Set this after initiating a new Room. */ public function get roomJID():UnescapedJID { return _roomJID; } public function set roomJID( jid:UnescapedJID ):void { _roomJID = jid; } /** * The room name that should be used when joining. */ public function get roomName():String { return _roomJID ? _roomJID.localpart : null; } public function set roomName( value:String ):void { roomJID = new UnescapedJID( value + ""@"" + conferenceServer ); } /** * The subject. */ public function get subject():String { return _subject; } /** * Get the JID of the conference room user. */ public function get userJID():UnescapedJID { return _roomJID ? new UnescapedJID( _roomJID.bareJID + ""/"" + nickname ) : null; } } } ",12520,False,2363.3316038039666,median "package com.ankamagames.berilia.components { import com.ankamagames.berilia.Berilia; import com.ankamagames.berilia.FinalizableUIComponent; import com.ankamagames.berilia.UIComponent; import com.ankamagames.berilia.components.messages.TextClickMessage; import com.ankamagames.berilia.events.LinkInteractionEvent; import com.ankamagames.berilia.factories.HyperlinkFactory; import com.ankamagames.berilia.managers.CssManager; import com.ankamagames.berilia.managers.TooltipManager; import com.ankamagames.berilia.managers.UiModuleManager; import com.ankamagames.berilia.types.LocationEnum; import com.ankamagames.berilia.types.data.ExtendedStyleSheet; import com.ankamagames.berilia.types.data.TextTooltipInfo; import com.ankamagames.berilia.types.graphic.ButtonContainer; import com.ankamagames.berilia.types.graphic.GraphicContainer; import com.ankamagames.berilia.types.graphic.UiRootContainer; import com.ankamagames.jerakine.data.XmlConfig; import com.ankamagames.jerakine.interfaces.IRectangle; import com.ankamagames.jerakine.logger.Log; import com.ankamagames.jerakine.logger.Logger; import com.ankamagames.jerakine.managers.FontManager; import com.ankamagames.jerakine.types.Callback; import com.ankamagames.jerakine.types.Uri; import com.ankamagames.jerakine.types.UserFont; import com.ankamagames.jerakine.utils.misc.DescribeTypeCache; import com.ankamagames.jerakine.utils.misc.StringUtils; import flash.display.BitmapData; import flash.display.DisplayObjectContainer; import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.events.TextEvent; import flash.filters.BitmapFilter; import flash.filters.DropShadowFilter; import flash.filters.GlowFilter; import flash.geom.Matrix; import flash.geom.Point; import flash.geom.Rectangle; import flash.text.AntiAliasType; import flash.text.GridFitType; import flash.text.StyleSheet; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFieldType; import flash.text.TextFormat; import flash.text.TextLineMetrics; import flash.utils.Dictionary; import flash.utils.getQualifiedClassName; import mx.utils.UIDUtil; public class Label extends GraphicContainer implements UIComponent, IRectangle, FinalizableUIComponent { public static var HEIGHT_OFFSET:int = 0; public static var MEMORY_LOG:Dictionary = new Dictionary(true); protected static const _log:Logger = Log.getLogger(getQualifiedClassName(Label)); private static const VALIGN_NONE:String = ""NONE""; private static const VALIGN_TOP:String = ""TOP""; private static const VALIGN_CENTER:String = ""CENTER""; private static const VALIGN_BOTTOM:String = ""BOTTOM""; private static const VALIGN_FIXEDHEIGHT:String = ""FIXEDHEIGHT""; private static const _filterIndex:Dictionary = new Dictionary(); protected var _tText:TextField; private var _cssApplied:Boolean = false; protected var _sText:String = """"; protected var _sType:String = ""default""; protected var _parseText:Boolean = true; private var _binded:Boolean = false; private var _needToFinalize:Boolean = false; private var _lastWidth:Number = -1; private var _uid:String = null; protected var _sCssUrl:Uri; protected var _nWidth:uint = 100; protected var _nHeight:uint = 20; protected var _bHtmlAllowed:Boolean = true; protected var _sAntialiasType:String = ""normal""; protected var _bFixedWidth:Boolean = true; protected var _hyperlinkEnabled:Boolean = false; protected var _bFixedHeight:Boolean = true; protected var _bFixedHeightForMultiline:Boolean = false; protected var _aStyleObj:Array; protected var _ssSheet:ExtendedStyleSheet; protected var _tfFormatter:TextFormat; protected var _useEmbedFonts:Boolean = true; protected var _useDefaultFont:Boolean = false; protected var _useFontResize:Boolean = true; protected var _nPaddingLeft:int = 0; protected var _nPaddingRight:int = 0; protected var _nTextIndent:int = 0; protected var _verticalOffset:Number = 0.0; protected var _bDisabled:Boolean; protected var _nTextHeight:int; protected var _sVerticalAlign:String = ""none""; protected var _useExtendWidth:Boolean = false; protected var _autoResize:Boolean = true; protected var _useStyleSheet:Boolean = false; protected var _currentStyleSheet:StyleSheet; protected var _useCustomFormat:Boolean = false; protected var _neverIndent:Boolean = false; protected var _hasHandCursor:Boolean = false; protected var _shiftClickActivated:Boolean = true; protected var _forceUppercase:Boolean = false; private var _useTooltipExtension:Boolean = true; private var _textFieldTooltipExtension:TextField; private var _textTooltipExtensionColor:uint; private var _mouseOverHyperLink:Boolean; private var _lastHyperLinkId:int; private var _hyperLinks:Array; protected var _sCssClass:String; public function Label() { super(); this.aStyleObj = new Array(); this.createTextField(); this._tText.type = TextFieldType.DYNAMIC; this._tText.selectable = false; this._tText.mouseEnabled = false; this.useFontResize = this._useFontResize; MEMORY_LOG[this] = 1; } public function get text() : String { return this._tText.text; } public function set text(sValue:String) : void { if(sValue == null) { sValue = """"; } if(this._forceUppercase) { sValue = sValue.toLocaleUpperCase(); } this._sText = sValue; if(this._bHtmlAllowed) { if(this._useStyleSheet) { this._tText.styleSheet = null; } this._tText.htmlText = sValue; if(!this._useCustomFormat) { if(this._sCssUrl != null && !this._cssApplied) { this.applyCSS(this._sCssUrl); this._cssApplied = true; } else { this.updateCss(); if(_bgColor != -1) { this.bgColor = _bgColor; } } } } else { this._tText.text = sValue; } if(!this._useCustomFormat && !this._sCssClass) { this.cssClass = ""p""; } if(this._hyperlinkEnabled) { HyperlinkFactory.createTextClickHandler(this._tText,this._useStyleSheet); HyperlinkFactory.createRollOverHandler(this._tText); this.parseLinks(); } if(this._currentStyleSheet) { if(this._hyperlinkEnabled) { sValue = HyperlinkFactory.decode(sValue); this.parseLinks(); } this._tText.styleSheet = this._currentStyleSheet; this._tText.htmlText = sValue; } if(_finalized && this._autoResize) { this.resizeText(); } } public function get htmlText() : String { return this._tText.htmlText; } public function set htmlText(val:String) : void { if(this._forceUppercase) { val = val.toLocaleUpperCase(); } this._tText.htmlText = val; if(this._hyperlinkEnabled) { HyperlinkFactory.createTextClickHandler(this._tText); HyperlinkFactory.createRollOverHandler(this._tText); this.parseLinks(); } } public function get parseText() : Boolean { return this._parseText; } public function set parseText(value:Boolean) : void { this._parseText = value; } public function get hyperlinkEnabled() : Boolean { return this._hyperlinkEnabled; } public function get mouseOverHyperLink() : Boolean { return this._mouseOverHyperLink; } public function set hyperlinkEnabled(bValue:Boolean) : void { this._hyperlinkEnabled = bValue; mouseEnabled = bValue; mouseChildren = bValue; this._tText.mouseEnabled = bValue; if(bValue) { this._hyperLinks = []; this._tText.addEventListener(MouseEvent.MOUSE_MOVE,this.onMouseMove); this._tText.addEventListener(MouseEvent.ROLL_OUT,this.hyperlinkRollOut); } else { this._tText.removeEventListener(MouseEvent.MOUSE_MOVE,this.onMouseMove); this._tText.removeEventListener(MouseEvent.ROLL_OUT,this.hyperlinkRollOut); } } public function get useStyleSheet() : Boolean { return this._useStyleSheet; } public function set useStyleSheet(bValue:Boolean) : void { this._useStyleSheet = bValue; } public function get useCustomFormat() : Boolean { return this._useCustomFormat; } public function set useCustomFormat(bValue:Boolean) : void { this._useCustomFormat = bValue; } public function get shiftClickActivated() : Boolean { return this._shiftClickActivated; } public function set shiftClickActivated(bValue:Boolean) : void { this._shiftClickActivated = bValue; } public function get neverIndent() : Boolean { return this._neverIndent; } public function set neverIndent(bValue:Boolean) : void { this._neverIndent = bValue; } public function get autoResize() : Boolean { return this._autoResize; } public function set autoResize(bValue:Boolean) : void { this._autoResize = bValue; } public function get caretIndex() : int { return this._tText.caretIndex; } public function set caretIndex(pos:int) : void { var lastPos:int = 0; if(pos == -1) { lastPos = this._tText.text.length; this._tText.setSelection(lastPos,lastPos); } else { this._tText.setSelection(pos,pos); } } public function selectAll() : void { this._tText.setSelection(0,this._tText.length); } public function getCharBoundaries(charPos:Number) : Rectangle { return this._tText.getCharBoundaries(charPos); } public function get type() : String { return this._sType; } public function set type(sValue:String) : void { this._sType = sValue; } [Uri] public function get css() : Uri { return this._sCssUrl; } [Uri] public function set css(sFile:Uri) : void { this._cssApplied = false; this.applyCSS(sFile); } public function set cssClass(c:String) : void { this._sCssClass = c == """" ? ""p"" : c; this.bindCss(); } public function get cssClass() : String { return this._sCssClass; } public function get antialias() : String { return this._sAntialiasType; } public function set antialias(s:String) : void { this._sAntialiasType = s; this._tText.antiAliasType = this._sAntialiasType; } public function get thickness() : int { return this._tText.thickness; } public function set thickness(value:int) : void { this._tText.thickness = value; } public function get forceUppercase() : Boolean { return this._forceUppercase; } public function set forceUppercase(value:Boolean) : void { this._forceUppercase = value; var currentText:String = this.text; this.text = currentText; } public function set aStyleObj(value:Object) : void { this._aStyleObj = value as Array; } public function get aStyleObj() : Object { return this._aStyleObj; } override public function get width() : Number { return this._useExtendWidth && this._tText.numLines < 2 ? Number(this._tText.textWidth + 7) : Number(this._nWidth); } override public function set width(nValue:Number) : void { if(nValue == 0) { return; } this._nWidth = nValue; this._tText.width = this._nWidth; super.width = nValue; if(!this._bFixedHeight) { this.bindCss(); } if(_finalized && this._autoResize) { this.resizeText(); } } override public function get height() : Number { return this._nHeight; } override public function set height(nValue:Number) : void { var valMin:Number = NaN; if(!this._tText.multiline) { valMin = this._tText.textHeight; if(nValue < valMin) { nValue = valMin; } } this._nHeight = nValue; this._tText.height = this._nHeight; __height = this._nHeight; if(_bgColor != -1) { this.bgColor = _bgColor; } this.updateAlign(); } public function get textWidth() : Number { return this._tText.textWidth; } public function get textHeight() : Number { return this._tText.textHeight; } public function get html() : Boolean { return this._bHtmlAllowed; } public function set html(bValue:Boolean) : void { this._bHtmlAllowed = bValue; } public function set wordWrap(bWordWrap:Boolean) : void { this._tText.wordWrap = bWordWrap; } public function get wordWrap() : Boolean { return this._tText.wordWrap; } public function set multiline(bMultiline:Boolean) : void { this._tText.multiline = bMultiline; } public function get multiline() : Boolean { return this._tText.multiline; } public function get border() : Boolean { return this._tText.border; } public function set border(bValue:Boolean) : void { this._tText.border = bValue; } public function get fixedWidth() : Boolean { return this._bFixedWidth; } public function set fixedWidth(bValue:Boolean) : void { this._bFixedWidth = bValue; if(this._bFixedWidth) { this._tText.autoSize = TextFieldAutoSize.NONE; } else { this._tText.autoSize = TextFieldAutoSize.LEFT; } } public function get useExtendWidth() : Boolean { return this._useExtendWidth; } public function set useExtendWidth(v:Boolean) : void { this._useExtendWidth = v; } public function get hasTooltipExtension() : Boolean { return this._textFieldTooltipExtension && this._textFieldTooltipExtension.text != """"; } public function get fixedHeight() : Boolean { return this._bFixedHeight; } public function set fixedHeight(bValue:Boolean) : void { this._bFixedHeight = bValue; if(this._tText.wordWrap && bValue) { _log.warn(""Setting wordWrap to false as fixedHeight has been set to true!""); } this._tText.wordWrap = !this._bFixedHeight; } public function get fixedHeightForMultiline() : Boolean { return this._bFixedHeightForMultiline; } public function set fixedHeightForMultiline(bValue:Boolean) : void { this._bFixedHeightForMultiline = bValue; } override public function set bgColor(nColor:*) : void { setColorVar(nColor); graphics.clear(); if(bgColor == -1 || !this.width || !this.height) { return; } if(_borderColor != -1) { graphics.lineStyle(1,_borderColor); } graphics.beginFill(_bgColor,_bgAlpha); if(!_bgCornerRadius) { graphics.drawRect(x - _bgMargin,y,this.width + _bgMargin * 2,this.height + 2); } else { graphics.drawRoundRect(this._tText.x - _bgMargin,this._tText.y,this._tText.width + _bgMargin * 2,this._tText.height + 2,_bgCornerRadius,_bgCornerRadius); } graphics.endFill(); } override public function set borderColor(nColor:int) : void { if(nColor == -1) { this._tText.border = false; } else { this._tText.border = true; this._tText.borderColor = nColor; } } public function set selectable(bValue:Boolean) : void { this._tText.selectable = bValue; } public function get length() : uint { return this._tText.length; } public function set scrollV(nVal:int) : void { this._tText.scrollV = nVal; } public function get scrollV() : int { this._tText.getCharBoundaries(0); return this._tText.scrollV; } public function get maxScrollV() : int { this._tText.getCharBoundaries(0); return this._tText.maxScrollV; } public function get textfield() : TextField { return this._tText; } public function get useEmbedFonts() : Boolean { return this._useEmbedFonts; } public function set useEmbedFonts(b:Boolean) : void { this._useEmbedFonts = b; this._tText.embedFonts = b; } override public function set disabled(bool:Boolean) : void { if(bool) { this._hasHandCursor = handCursor; handCursor = false; mouseEnabled = false; this._tText.mouseEnabled = false; } else { if(!handCursor) { handCursor = this._hasHandCursor; } mouseEnabled = true; this._tText.mouseEnabled = true; } this._bDisabled = bool; } public function get verticalAlign() : String { return this._sVerticalAlign; } public function set verticalAlign(s:String) : void { this._sVerticalAlign = s; this.updateAlign(); } public function get textFormat() : TextFormat { return this._tfFormatter; } public function set textFormat(tf:TextFormat) : void { this._tfFormatter = tf; this._tText.setTextFormat(this._tfFormatter); } public function set restrict(restrictTo:String) : void { this._tText.restrict = restrictTo; } public function get restrict() : String { return this._tText.restrict; } public function set colorText(color:uint) : void { if(!this._tfFormatter) { _log.error(""Error. Try to change the size before formatter was initialized.""); return; } this._tfFormatter.color = color; this._tText.setTextFormat(this._tfFormatter); this._tText.defaultTextFormat = this._tfFormatter; } public function get useDefaultFont() : Boolean { return this._useDefaultFont; } public function set useDefaultFont(value:Boolean) : void { this._useDefaultFont = value; } public function get useFontResize() : Boolean { return this._useFontResize; } public function set useFontResize(value:Boolean) : void { this._useFontResize = value; if(this._useFontResize) { FontManager.getInstance().addEventListener(Event.CHANGE,this.onFontConfigChange,false,0,true); } else { FontManager.getInstance().removeEventListener(Event.CHANGE,this.onFontConfigChange,false); } } public function setCssColor(color:String, style:String = null) : void { this.changeCssClassColor(color,style); } public function setCssSize(size:uint, style:String = null) : void { this.changeCssClassSize(size,style); } public function setCssFont(font:String, style:String = null) : void { this.changeCssClassFont(font,style); } public function setStyleSheet(styles:StyleSheet) : void { this._useStyleSheet = true; this._currentStyleSheet = styles; this._tText.styleSheet = this._currentStyleSheet; } protected function onFontConfigChange(event:Event) : void { this.bindCss(); } public function applyCSS(sFile:Uri) : void { if(sFile == null) { return; } if(sFile == this._sCssUrl && this._tfFormatter) { this.updateCss(); } else { this._sCssUrl = sFile; CssManager.getInstance().askCss(sFile.uri,new Callback(this.bindCss)); } } public function setBorderColor(nColor:int) : void { this._tText.borderColor = nColor; } public function allowTextMouse(bValue:Boolean) : void { this.mouseChildren = bValue; this._tText.mouseEnabled = bValue; } override public function remove() : void { super.remove(); if(this._tText && this._tText.parent) { removeChild(this._tText); } if(this._uid) { TooltipManager.hide(""TextExtension"" + this._uid); } if(this._tText) { this._tText.removeEventListener(MouseEvent.MOUSE_MOVE,this.onMouseMove); this._tText.removeEventListener(MouseEvent.ROLL_OUT,this.hyperlinkRollOut); this._tText.removeEventListener(TextEvent.LINK,this.onTextClick); HyperlinkFactory.deactiveSmallHyperlink(this._tText); HyperlinkFactory.removeTextClickHandler(this._tText); HyperlinkFactory.removeRollOverHandler(this._tText); } if(this._textFieldTooltipExtension) { this._textFieldTooltipExtension.removeEventListener(MouseEvent.ROLL_OVER,this.onTooltipExtensionOver); this._textFieldTooltipExtension.removeEventListener(MouseEvent.ROLL_OUT,this.onTooltipExtensionOut); this._textFieldTooltipExtension.removeEventListener(MouseEvent.MOUSE_WHEEL,this.onTooltipExtensionOut); } FontManager.getInstance().removeEventListener(Event.CHANGE,this.onFontConfigChange,false); } override public function free() : void { super.free(); this._sType = ""default""; this._nWidth = 100; this._nHeight = 20; this._bHtmlAllowed = true; this._sAntialiasType = AntiAliasType.NORMAL; this._bFixedWidth = true; this._bFixedHeight = true; this._bFixedHeightForMultiline = false; this._ssSheet = null; this._useEmbedFonts = true; this._nPaddingLeft = 0; this._nPaddingRight = 0; this._nTextIndent = 0; this._bDisabled = false; this._nTextHeight = 0; this._sVerticalAlign = ""none""; this._useExtendWidth = false; this._sCssClass = null; this._tText.type = TextFieldType.DYNAMIC; this._tText.selectable = false; } private function createTextField() : void { this._tText = new TextField(); this._tText.addEventListener(TextEvent.LINK,this.onTextClick); addChild(this._tText); } private function changeCssClassColor(color:String, style:String = null) : void { var i:* = undefined; if(style) { if(this.aStyleObj[style] == null) { this.aStyleObj[style] = new Object(); } this.aStyleObj[style].color = color; if(this._ssSheet) { this._tfFormatter = this._ssSheet.transform(this.aStyleObj[style]); this._tText.setTextFormat(this._tfFormatter); this._tText.defaultTextFormat = this._tfFormatter; } } else { for each(i in this.aStyleObj) { i.color = color; } } } private function changeCssClassSize(size:uint, style:String = null) : void { var currentStyleSheet:StyleSheet = null; var i:* = undefined; if(style) { if(this.aStyleObj[style] == null) { this.aStyleObj[style] = new Object(); } this.aStyleObj[style].fontSize = size; if(this._ssSheet) { currentStyleSheet = this._tText.styleSheet; this._tText.styleSheet = null; this._tfFormatter = this._ssSheet.transform(this.aStyleObj[style]); this._tText.setTextFormat(this._tfFormatter); this._tText.defaultTextFormat = this._tfFormatter; this._tText.styleSheet = currentStyleSheet; } } else { for each(i in this.aStyleObj) { i.fontSize = size; } } } private function changeCssClassFont(font:String, style:String = null) : void { var i:* = undefined; if(style) { if(this.aStyleObj[style] == null) { this.aStyleObj[style] = new Object(); } this.aStyleObj[style].fontFamily = font; } else { for each(i in this.aStyleObj) { i.fontFamily = font; } } } public function appendText(sTxt:String, style:String = null) : void { var textFormat:TextFormat = null; if(this._forceUppercase) { sTxt = sTxt.toLocaleUpperCase(); } if(style && this.aStyleObj[style] && this._ssSheet) { if(this._tText.filters.length) { this._tText.filters = new Array(); } textFormat = this._ssSheet.transform(this.aStyleObj[style]); if(!textFormat.bold) { textFormat.bold = false; } this._tText.defaultTextFormat = textFormat; } if(this._hyperlinkEnabled) { sTxt = HyperlinkFactory.decode(sTxt); } this._tText.htmlText += sTxt; if(this._hyperlinkEnabled) { this.parseLinks(); } } public function activeSmallHyperlink() : void { HyperlinkFactory.activeSmallHyperlink(this._tText); } private function bindCss() : void { var styleToDisplay:String = null; var s:String = null; var effectName:String = null; var filtersTmp:Array = null; var filterRef:Dictionary = null; var cssKey:String = null; var oldCssUrl:Uri = null; var filter:BitmapFilter = null; var valueString:String = null; var value:* = undefined; var oldSize:Number = NaN; var font:String = null; if(!this._sCssUrl) { if(this._needToFinalize) { this.finalize(); } return; } var oldCss:ExtendedStyleSheet = this._ssSheet; this._ssSheet = CssManager.getInstance().getCss(this._sCssUrl.uri); if(!this._ssSheet) { if(oldCss == null) { if(this._needToFinalize) { this.finalize(); } return; } this._ssSheet = oldCss; oldCssUrl = this._sCssUrl; this._sCssUrl = null; this.applyCSS(oldCssUrl); } var currentStyleSheet:StyleSheet = this._tText.styleSheet; this._tText.styleSheet = null; this.aStyleObj = new Array(); for each(s in this._ssSheet.styleNames) { if(!styleToDisplay || s == this._sCssClass || this._sCssClass != styleToDisplay && s == ""p"") { styleToDisplay = s; } if(this._ssSheet != oldCss || !this.aStyleObj[s]) { this.aStyleObj[s] = this._ssSheet.getStyle(s); } } filtersTmp = []; filterRef = new Dictionary(); for(cssKey in this.aStyleObj[styleToDisplay]) { effectName = cssKey.indexOf(""shadow"") != -1 ? ""shadow"" : null; effectName = !effectName && cssKey.indexOf(""glow"") != -1 ? ""glow"" : effectName; if(effectName) { if(!filterRef[effectName]) { if(effectName == ""shadow"") { filter = new DropShadowFilter(); } else if(effectName == ""glow"") { filter = new GlowFilter(); } this.buildFilterIndex(filter); filtersTmp.push(filter); filterRef[effectName] = filter; } else { filter = filterRef[effectName]; } try { valueString = this.aStyleObj[styleToDisplay][cssKey]; if(valueString.charAt(0) == ""#"") { value = parseInt(valueString.substr(1),16); } else { value = parseFloat(valueString); } filter[_filterIndex[getQualifiedClassName(filter)][cssKey.substr(effectName.length).toLowerCase()]] = value; } catch(e:Error) { _log.error(e); } } } filters = filtersTmp; if(this.aStyleObj[styleToDisplay][""useEmbedFonts""]) { this._useEmbedFonts = this.aStyleObj[styleToDisplay][""useEmbedFonts""] == ""true""; } if(this.aStyleObj[styleToDisplay][""paddingLeft""]) { this._nPaddingLeft = parseInt(this.aStyleObj[styleToDisplay][""paddingLeft""]); } if(this.aStyleObj[styleToDisplay][""paddingRight""]) { this._nPaddingRight = parseInt(this.aStyleObj[styleToDisplay][""paddingRight""]); } if(this.aStyleObj[styleToDisplay][""verticalHeight""]) { this._nTextHeight = parseInt(this.aStyleObj[styleToDisplay][""verticalHeight""]); } if(this.aStyleObj[styleToDisplay][""verticalAlign""]) { this.verticalAlign = this.aStyleObj[styleToDisplay][""verticalAlign""]; } if(this.aStyleObj[styleToDisplay][""thickness""]) { this._tText.thickness = this.aStyleObj[styleToDisplay][""thickness""]; } this._tText.gridFitType = GridFitType.PIXEL; this._tText.htmlText = !!this._sText ? this._sText : this.htmlText; this._tfFormatter = this._ssSheet.transform(this.aStyleObj[styleToDisplay]); if(this.aStyleObj[styleToDisplay][""leading""]) { this._tfFormatter.leading = this.aStyleObj[styleToDisplay][""leading""]; } if(this.aStyleObj[styleToDisplay][""letterSpacing""]) { this._tfFormatter.letterSpacing = parseFloat(this.aStyleObj[styleToDisplay][""letterSpacing""]); } if(this.aStyleObj[styleToDisplay][""kerning""]) { this._tfFormatter.kerning = this.aStyleObj[styleToDisplay][""kerning""] == ""true""; } if(!this._neverIndent) { this._tfFormatter.indent = this._nTextIndent; } this._tfFormatter.leftMargin = this._nPaddingLeft; this._tfFormatter.rightMargin = this._nPaddingRight; var fontInfo:UserFont = FontManager.getInstance().getFontInfo(this._tfFormatter.font,this._useDefaultFont); if(this._useEmbedFonts) { if(fontInfo) { oldSize = this._tfFormatter.size != null ? Number(Number(this._tfFormatter.size)) : Number(12); if(fontInfo.maxSize != UserFont.FONT_SIZE_NO_MAX && this._tfFormatter.size < fontInfo.maxSize) { this._tfFormatter.size = Math.min(Math.round(int(this._tfFormatter.size) * fontInfo.sizeMultiplicator),fontInfo.maxSize != UserFont.FONT_SIZE_NO_MAX ? Number(fontInfo.maxSize) : Number(1000)); this._verticalOffset = ((this._tfFormatter.size != null ? Number(this._tfFormatter.size) : 12) - oldSize) * fontInfo.verticalOffset; } this._tfFormatter.font = fontInfo.className; this._tText.defaultTextFormat.font = fontInfo.className; this._tText.embedFonts = true; this._tText.antiAliasType = AntiAliasType.ADVANCED; this._tText.sharpness = fontInfo.sharpness; if(this._tfFormatter.letterSpacing < fontInfo.letterSpacing) { this._tfFormatter.letterSpacing = fontInfo.letterSpacing; } if(this._tfFormatter.letterSpacing == null) { this._tfFormatter.letterSpacing = 0.0001; } } else if(this._tfFormatter) { _log.warn(""System font ["" + this._tfFormatter.font + ""] used (in "" + (!!getUi() ? getUi().name : ""unknow"") + "", from "" + this._sCssUrl.uri + "")""); } else { _log.fatal(""Erreur de formattage.""); } } else { font = !!fontInfo ? fontInfo.realName : """"; this._tfFormatter.font = font != """" ? font : this._tfFormatter.font; this._tText.embedFonts = false; } this._tText.setTextFormat(this._tfFormatter); this._tText.defaultTextFormat = this._tfFormatter; if(this._hyperlinkEnabled) { HyperlinkFactory.createTextClickHandler(this._tText,true); HyperlinkFactory.createRollOverHandler(this._tText); this.parseLinks(); } this._tText.styleSheet = currentStyleSheet; if(this._nTextHeight) { this._tText.height = this._nTextHeight; this._tText.y += this._nHeight / 2 - this._tText.height / 2; } else if(!this._bFixedHeight) { this._tText.height = this._tText.textHeight + 5; this._nHeight = this._tText.height; } else { this._tText.height = this._nHeight; } if(this._useExtendWidth) { this._tText.width = this._tText.textWidth + 7; this._nWidth = this._tText.width; } if(_bgColor != -1) { this.bgColor = _bgColor; } this.updateAlign(); if(this._useExtendWidth && getUi()) { getUi().render(); } this._binded = true; this.updateTooltipExtensionStyle(); if(this._needToFinalize) { this.finalize(); } } public function updateCss() : void { if(!this._tfFormatter) { return; } this._tText.setTextFormat(this._tfFormatter); this._tText.defaultTextFormat = this._tfFormatter; this.updateTooltipExtensionStyle(); if(!this._bFixedHeight) { this._tText.height = this._tText.textHeight + 5; this._nHeight = this._tText.height; } else { this._tText.height = this._nHeight; } if(this._useExtendWidth) { this._tText.width = this._tText.textWidth + 7; this._nWidth = this._tText.width; } if(_bgColor != -1) { this.bgColor = _bgColor; } this.updateAlign(); if(this._useExtendWidth && getUi()) { getUi().render(); } } public function updateTextFormatProperty(pPropertyName:String, pPropertyValue:*) : void { this._tfFormatter[pPropertyName] = pPropertyValue; this.updateCss(); } public function fullSize(width:int) : void { this.removeTooltipExtension(); this._nWidth = width; this._tText.width = width; var tHeight:uint = this._tText.textHeight + 8; this._tText.height = tHeight; this._nHeight = tHeight; } public function fullWidthAndHeight(maxWidth:uint = 0, offsetWidth:uint = 5) : void { this._nWidth = int(this._tText.textWidth + offsetWidth); this._tText.width = this._nWidth; if(maxWidth > 0) { this._nWidth = maxWidth; this._tText.width = maxWidth; if(this._tText.textWidth < maxWidth) { this._tText.width = this._tText.textWidth + 10; } } this._nHeight = this._tText.textHeight + 8; this._tText.height = this._nHeight; } public function fullWidth(maxWidth:uint = 0, offsetWidth:uint = 5) : void { this._nWidth = int(this._tText.textWidth + offsetWidth); this._tText.width = this._nWidth; if(maxWidth > 0) { this._nWidth = maxWidth; this._tText.width = maxWidth; if(this._tText.textWidth < maxWidth) { this._tText.width = this._tText.textWidth + 10; } } } public function resizeText() : void { var needTooltipExtension:Boolean = false; var currentTextFieldWidth:int = 0; this.removeTooltipExtension(); if((this._bFixedHeight && !this._tText.multiline || this._bFixedHeightForMultiline) && this._tText.autoSize == ""none"" && this._tfFormatter) { needTooltipExtension = false; currentTextFieldWidth = this._tText.width; if(this._tText.textWidth > currentTextFieldWidth + 1 || this._tText.textHeight > this._tText.height || this._bFixedHeightForMultiline && this._tText.textHeight > this.height) { if(this._useTooltipExtension) { needTooltipExtension = true; } else { _log.warn(""Attention : Ce texte est beaucoup trop long pour entrer dans ce TextField (Texte : "" + this._tText.text + "")""); } } if(needTooltipExtension && (!this.multiline && this._bFixedHeight || this._bFixedHeightForMultiline)) { this.addTooltipExtension(); } else if(this._lastWidth != this._tText.width) { this._lastWidth = this._tText.width; } } } public function truncateText(pMaxHeight:Number, pCleanTruncature:Boolean = true) : void { var numLines:int = 0; var nbVisibleLines:int = 0; var nbVisibleChars:int = 0; var i:int = 0; var h:Number = NaN; var lineHeight:Number = NaN; var lineBreakIndex:int = 0; var periodIndex:int = 0; this._nHeight = __height = this._tText.height = pMaxHeight; if(this._tText.wordWrap && this._tText.numLines > 0) { numLines = this._tText.numLines; h = 4; lineHeight = this._tText.getLineMetrics(0).height; for(i = 0; i < numLines; i++) { h += lineHeight; if(h >= this._tText.height) { break; } nbVisibleLines++; nbVisibleChars += this._tText.getLineLength(i); } this._tText.text = this._tText.text.substr(0,nbVisibleChars); if(pCleanTruncature) { lineBreakIndex = this._tText.text.lastIndexOf(String.fromCharCode(10)); periodIndex = this._tText.text.lastIndexOf("".""); if(lineBreakIndex != -1 || periodIndex != -1) { this._tText.text = this._tText.text.substring(0,Math.max(lineBreakIndex,periodIndex)); this._tText.appendText("" ("" + String.fromCharCode(8230) + "")""); this._nHeight = __height = this._tText.height = this._tText.height - (nbVisibleLines - this._tText.numLines) * lineHeight; } else { this.addEllipsis(); } } else { this.addEllipsis(); } } } public function removeTooltipExtension() : void { if(this._textFieldTooltipExtension) { removeChild(this._textFieldTooltipExtension); this._tText.width = __width + int(this._textFieldTooltipExtension.width + 2); __width = this._tText.width; this._textFieldTooltipExtension.removeEventListener(MouseEvent.ROLL_OVER,this.onTooltipExtensionOver); this._textFieldTooltipExtension.removeEventListener(MouseEvent.ROLL_OUT,this.onTooltipExtensionOut); this._textFieldTooltipExtension = null; } } private function buildFilterIndex(target:BitmapFilter) : void { var field:String = null; var className:String = getQualifiedClassName(target); if(_filterIndex[className]) { return; } var index:Dictionary = new Dictionary(); for each(field in DescribeTypeCache.getVariables(target)) { index[field.toLowerCase()] = field; } _filterIndex[className] = index; } private function addEllipsis() : void { var i:int = 0; var nbSpaces:int = 0; if(this._tText.text.length - 3 > 0) { this._tText.text = this._tText.text.substr(0,this._tText.text.length - 3); i = this._tText.text.length - 1; while(i >= 0 && this._tText.text.charAt(i) == "" "") { nbSpaces++; i--; } if(nbSpaces > 0) { this._tText.text = this._tText.text.substr(0,this._tText.text.length - nbSpaces); } this._tText.appendText(String.fromCharCode(8230)); } } public function addTooltipExtension() : void { this._textFieldTooltipExtension = new TextField(); this._textFieldTooltipExtension.selectable = false; this._textFieldTooltipExtension.height = 1; this._textFieldTooltipExtension.width = 1; this._textFieldTooltipExtension.autoSize = TextFieldAutoSize.LEFT; this.updateTooltipExtensionStyle(); this._textFieldTooltipExtension.text = ""...""; this._textFieldTooltipExtension.name = ""extension_"" + name; addChild(this._textFieldTooltipExtension); var w:int = this._textFieldTooltipExtension.width + 2; this._tText.width -= w; __width = this._tText.width; this._textFieldTooltipExtension.x = this._tText.width; this._textFieldTooltipExtension.y = this._tText.y + this._tText.height - this._textFieldTooltipExtension.textHeight - 10; if(!this._tText.wordWrap) { this._textFieldTooltipExtension.y = this._tText.y; this._tText.height = this._tText.textHeight + 3; __height = this._tText.height; } else if(this._bFixedHeightForMultiline) { this._tText.height = this.height + 3; __height = this._tText.height; switch(this._sVerticalAlign.toUpperCase()) { case VALIGN_CENTER: this._tText.y = (this.height - this._tText.height) / 2; break; case VALIGN_BOTTOM: this._tText.y = this.height - this._tText.height; break; default: this._tText.y = 0; } this._textFieldTooltipExtension.y = this._tText.y + this.height - this._textFieldTooltipExtension.textHeight; } var target:DisplayObjectContainer = this; for(var i:int = 0; i < 4; i++) { if(target is ButtonContainer) { (target as ButtonContainer).mouseChildren = true; break; } target = target.parent; if(!target) { break; } } this._textFieldTooltipExtension.addEventListener(MouseEvent.ROLL_OVER,this.onTooltipExtensionOver,false,0,true); this._textFieldTooltipExtension.addEventListener(MouseEvent.ROLL_OUT,this.onTooltipExtensionOut,false,0,true); this._textFieldTooltipExtension.addEventListener(MouseEvent.MOUSE_WHEEL,this.onTooltipExtensionOut,false,0,true); } private function updateTooltipExtensionStyle() : void { if(!this._textFieldTooltipExtension) { return; } this._textFieldTooltipExtension.embedFonts = this._tText.embedFonts; this._textFieldTooltipExtension.defaultTextFormat = this._tfFormatter; this._textFieldTooltipExtension.setTextFormat(this._tfFormatter); this._textTooltipExtensionColor = uint(this._tfFormatter.color); this._textFieldTooltipExtension.textColor = this._textTooltipExtensionColor; } private function onTextClick(e:TextEvent) : void { e.stopPropagation(); Berilia.getInstance().handler.process(new TextClickMessage(this,e.text)); } protected function updateAlign() : void { if(!this._tText.textHeight) { return; } var h:int = 0; for(var i:int = 0; i < this._tText.numLines; i++) { h += TextLineMetrics(this._tText.getLineMetrics(i)).height + TextLineMetrics(this._tText.getLineMetrics(i)).leading + TextLineMetrics(this._tText.getLineMetrics(i)).descent; } this._tText.y = 0; switch(this._sVerticalAlign.toUpperCase()) { case VALIGN_CENTER: this._tText.height = h; this._tText.y = (this.height - this._tText.height) / 2; break; case VALIGN_BOTTOM: this._tText.height = this.height; this._tText.y = this.height - h; break; case VALIGN_TOP: this._tText.height = h; this._tText.y = 0; break; case VALIGN_FIXEDHEIGHT: if(!this._tText.wordWrap || this._tText.multiline) { this._tText.height = this._tText.textHeight + HEIGHT_OFFSET; } this._tText.y = 0; break; case VALIGN_NONE: if(!this._tText.wordWrap || this._tText.multiline) { this._tText.height = this._tText.textHeight + 4 + HEIGHT_OFFSET; } this._tText.y = 0; } if(this._tfFormatter && FontManager.getInstance().getFontInfo(this._tfFormatter.font)) { this._tText.y += this._verticalOffset; } } private function onTooltipExtensionOver(e:MouseEvent) : void { var docMain:Sprite = Berilia.getInstance().docMain; if(this._uid == null) { this._uid = UIDUtil.createUID(); } TooltipManager.show(new TextTooltipInfo(this._tText.text),this,UiModuleManager.getInstance().getModule(""Ankama_Tooltips""),false,""TextExtension"" + this._uid,LocationEnum.POINT_TOP,LocationEnum.POINT_BOTTOM,20,true,null,TooltipManager.defaultTooltipUiScript,null,""TextInfo"" + this._uid); this._textFieldTooltipExtension.textColor = XmlConfig.getInstance().getEntry(""colors.hyperlink.link""); } private function onTooltipExtensionOut(e:MouseEvent = null) : void { TooltipManager.hide(""TextExtension"" + this._uid); this._textFieldTooltipExtension.textColor = this._textTooltipExtensionColor; } override public function finalize() : void { var ui:UiRootContainer = null; if(this._binded) { if(this._autoResize) { this.resizeText(); } if(this._hyperlinkEnabled) { HyperlinkFactory.createTextClickHandler(this._tText); HyperlinkFactory.createRollOverHandler(this._tText); this.parseLinks(); } _finalized = true; super.finalize(); ui = getUi(); if(ui) { ui.iAmFinalized(this); } } else { this._needToFinalize = true; } } public function get bmpText() : BitmapData { var m:Matrix = new Matrix(); var bmpdt:BitmapData = new BitmapData(this.width,this.height,true,16711680); bmpdt.draw(this._tText,m,null,null,null,true); return bmpdt; } private function parseLinks() : void { var textrun:Object = null; var textrunText:String = null; var openSquareBrackets:Array = null; var closeSquareBrackets:Array = null; var nbBrackets:int = 0; var i:int = 0; var j:int = 0; var textruns:Array = this._tText.getTextRuns(); var nbRuns:int = textruns.length; this._lastHyperLinkId = -1; this._hyperLinks.length = 0; for(i = 0; i < nbRuns; i++) { textrun = textruns[i]; if(textrun.textFormat && textrun.textFormat.url.length > 0) { textrunText = this._tText.text.substring(textrun.beginIndex,textrun.endIndex); openSquareBrackets = StringUtils.getAllIndexOf(""["",textrunText); closeSquareBrackets = StringUtils.getAllIndexOf(""]"",textrunText); if(openSquareBrackets.length > 1 && openSquareBrackets.length == closeSquareBrackets.length) { nbBrackets = openSquareBrackets.length; for(j = 0; j < nbBrackets; j++) { this._hyperLinks.push({ ""beginIndex"":textrun.beginIndex + openSquareBrackets[j], ""endIndex"":textrun.beginIndex + closeSquareBrackets[j], ""textFormat"":textrun.textFormat }); } } else { this._hyperLinks.push(textrun); } } } } private function getHyperLinkId(pCharIndex:int) : int { var i:int = 0; var nbLinks:int = this._hyperLinks.length; for(i = 0; i < nbLinks; i++) { if(pCharIndex >= this._hyperLinks[i].beginIndex && pCharIndex <= this._hyperLinks[i].endIndex) { return i; } } return -1; } private function onMouseMove(pEvent:MouseEvent) : void { var charIndex:int = 0; var textHeight:Number = NaN; var nbVisibleLines:int = 0; var lineHeight:Number = NaN; var i:int = 0; var numLines:int = 0; var bottomMargin:Number = NaN; var labelGlobalPos:Point = null; var mouseOverText:Boolean = false; var hyperLinkId:int = 0; var url:String = null; var params:Array = null; var type:String = null; var posY:int = 0; var data:String = null; if(this._tText.length > 0) { charIndex = this._tText.getCharIndexAtPoint(pEvent.localX,pEvent.localY); textHeight = 4; lineHeight = this._tText.getLineMetrics(0).height; numLines = this._tText.numLines; for(i = 0; i < numLines; i++) { textHeight += lineHeight; if(textHeight > this._tText.height) { break; } nbVisibleLines++; } bottomMargin = this._tText.height - nbVisibleLines * lineHeight; labelGlobalPos = localToGlobal(new Point(x,y)); mouseOverText = pEvent.stageY > labelGlobalPos.y + this._tText.height - bottomMargin ? false : true; if(mouseOverText && charIndex != -1) { hyperLinkId = this.getHyperLinkId(charIndex); url = hyperLinkId >= 0 ? this._hyperLinks[hyperLinkId].textFormat.url : null; if(url) { if(this._mouseOverHyperLink && (this._lastHyperLinkId >= 0 && hyperLinkId != this._lastHyperLinkId)) { this._mouseOverHyperLink = true; this.hyperlinkRollOut(); } if(!this._mouseOverHyperLink) { params = url.replace(""event:"","""").split("",""); type = params.shift(); posY = labelGlobalPos.y + this._tText.getCharBoundaries(charIndex).y; data = type + "","" + Math.round(pEvent.stageX) + "","" + Math.round(posY) + "","" + params.join("",""); this._tText.dispatchEvent(new LinkInteractionEvent(LinkInteractionEvent.ROLL_OVER,data)); this._mouseOverHyperLink = true; this._lastHyperLinkId = hyperLinkId; } } else { this.hyperlinkRollOut(); } } else { this.hyperlinkRollOut(); } } } private function hyperlinkRollOut(pEvent:MouseEvent = null) : void { if(pEvent || this._mouseOverHyperLink) { TooltipManager.hideAll(); this._tText.dispatchEvent(new LinkInteractionEvent(LinkInteractionEvent.ROLL_OUT)); } this._mouseOverHyperLink = false; } } } ",12463,False,2440.17494110476,median "/* UserPtr.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Requires -DU8X8_WITH_USER_PTR */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8g2lib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1306_72X40_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_WS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_RAYSTAR_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_RAYSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_KS0713_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_KS0713_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7567_HEM6432_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_IST7920_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_IST7920_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_DEM240064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1617_JLX128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1617_JLX128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list void setup(void) { /* U8g2 Project: SSD1306 Test Board */ //pinMode(10, OUTPUT); //pinMode(9, OUTPUT); //digitalWrite(10, 0); //digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); /* U8g2 Project: LC7981 Test Board, connect RW to GND */ //pinMode(17, OUTPUT); //digitalWrite(17, 0); /* U8g2 Project: Pax Instruments Shield: Enable Backlight */ //pinMode(6, OUTPUT); //digitalWrite(6, 0); u8g2.begin(); u8g2.setUserPtr((void *)""User Ptr Data""); } void loop(void) { u8g2.firstPage(); do { u8g2.setFont(u8g2_font_ncenR12_tr); u8g2.drawStr(0,24, (char *)u8g2.getUserPtr()); } while ( u8g2.nextPage() ); delay(1000); } ",16179,True,5016.238813357618,median "package com.company.assembleegameclient.objects { import com.company.assembleegameclient.map.Camera; import com.company.assembleegameclient.map.Square; import com.company.assembleegameclient.map.mapoverlay.CharacterStatusText; import com.company.assembleegameclient.objects.particles.HealingEffect; import com.company.assembleegameclient.objects.particles.LevelUpEffect; import com.company.assembleegameclient.parameters.Parameters; import com.company.assembleegameclient.parameters.Parameters; import com.company.assembleegameclient.sound.SoundEffectLibrary; import com.company.assembleegameclient.tutorial.Tutorial; import com.company.assembleegameclient.tutorial.doneAction; import com.company.assembleegameclient.util.AnimatedChar; import com.company.assembleegameclient.util.ConditionEffect; import com.company.assembleegameclient.util.FameUtil; import com.company.assembleegameclient.util.FreeList; import com.company.assembleegameclient.util.MaskedImage; import com.company.assembleegameclient.util.TextureRedrawer; import com.company.assembleegameclient.util.redrawers.GlowRedrawer; import com.company.util.CachingColorTransformer; import com.company.util.ConversionUtil; import com.company.util.GraphicsUtil; import com.company.util.IntPoint; import com.company.util.MoreColorUtil; import com.company.util.PointUtil; import com.company.util.Trig; import flash.display.BitmapData; import flash.display.GraphicsPath; import flash.display.GraphicsSolidFill; import flash.display.IGraphicsData; import flash.geom.ColorTransform; import flash.geom.Matrix; import flash.geom.Point; import flash.geom.Vector3D; import flash.utils.Dictionary; import flash.utils.getTimer; import kabam.rotmg.assets.services.CharacterFactory; import kabam.rotmg.chat.model.ChatMessage; import kabam.rotmg.constants.ActivationType; import kabam.rotmg.constants.GeneralConstants; import kabam.rotmg.constants.UseType; import kabam.rotmg.core.StaticInjectorContext; import kabam.rotmg.game.model.PotionInventoryModel; import kabam.rotmg.game.signals.AddTextLineSignal; import kabam.rotmg.game.view.components.QueuedStatusText; import kabam.rotmg.messaging.impl.data.StatData; import kabam.rotmg.stage3D.GraphicsFillExtra; import kabam.rotmg.text.model.NumberKey; import kabam.rotmg.text.model.TextKey; import kabam.rotmg.text.view.BitmapTextFactory; import kabam.rotmg.text.view.stringBuilder.LineBuilder; import kabam.rotmg.text.view.stringBuilder.StaticStringBuilder; import kabam.rotmg.text.view.stringBuilder.StringBuilder; import kabam.rotmg.ui.model.TabStripModel; import org.swiftsuspenders.Injector; public class Player extends Character { public static const MS_BETWEEN_TELEPORT:int = 10000; private static const MOVE_THRESHOLD:Number = 0.4; private static const NEARBY:Vector. = new [new Point(0, 0), new Point(1, 0), new Point(0, 1), new Point(1, 1)]; private static const RANK_OFFSET_MATRIX:Matrix = new Matrix(1, 0, 0, 1, 2, 2); private static const NAME_OFFSET_MATRIX:Matrix = new Matrix(1, 0, 0, 1, 20, 1); private static const MIN_MOVE_SPEED:Number = 0.004; private static const MAX_MOVE_SPEED:Number = 0.0096; private static const MIN_ATTACK_MULT:Number = 0.5; private static const MAX_ATTACK_MULT:Number = 2; private static const LOW_HEALTH_CT_OFFSET:int = 128; private static var lowHealthCT:Dictionary = new Dictionary(); public static var empiresCoin_:int = 0; public static var accountType_:int = 0; public static var isAdmin:Boolean = false; public static var isMod:Boolean = false; private static var newP:Point = new Point(); public var petObjectId:int = 0; public var petHpHealingAverageMin:int = 0; public var petHpHealingAverageMax:int = 0; public var petHpHealingAverageBonus:int = 0; public var petMpHealingAverageMin:int = 0; public var petMpHealingAverageMax:int = 0; public var petMpHealingAverageBonus:int = 0; public var petAttackCooldown:int = 0; public var petAttackChance:int = 0; public var petAttackDamageMin:int = 0; public var petAttackDamageMax:int = 0; public var isTrading:Boolean = false; public var xpTimer:int; public var skinId:int; public var skin:AnimatedChar; public var isShooting:Boolean; public var accountId_:String = """"; public var credits_:int = 0; public var tokens_:int = 0; public var numStars_:int = 0; public var fame_:Number = 0; public var nameChosen_:Boolean = false; public var currFame_:Number = 0; public var nextClassQuestFame_:Number = -1; public var guildName_:String = null; public var guildRank_:int = -1; public var isFellowGuild_:Boolean = false; public var breath_:int = -1; public var maxMP_:int = 200; public var mp_:Number = 0; public var nextLevelExp_:Number = 1000; public var nextAttackExp_:Number = 1000; public var nextDefenseExp_:Number = 1000; public var exp_:Number = 0; public var attackExp_:Number = 0; public var defenseExp_:Number = 0; public var attack_:String = null; public var speed_:String = null; public var dexterity_:String = null; public var vitality_:String = null; public var wisdom_:String = null; public var maxHPBoost_:String = null; public var maxMPBoost_:String = null; public var attackBoost_:String = null; public var defenseBoost_:String = null; public var speedBoost_:String = null; public var vitalityBoost_:String = null; public var wisdomBoost_:String = null; public var dexterityBoost_:String = null; public var xpBoost_:int = 0; public var healthPotionCount_:int = 0; public var magicPotionCount_:int = 0; public var attackMax_:int = 0; public var defenseMax_:int = 0; public var speedMax_:int = 0; public var dexterityMax_:int = 0; public var vitalityMax_:int = 0; public var wisdomMax_:int = 0; public var maxHPMax_:int = 0; public var maxMPMax_:int = 0; public var hasBackpack_:Boolean = false; public var accountType_:int = 0; public var admin_:Boolean = false; public var starred_:Boolean = false; public var ignored_:Boolean = false; public var distSqFromThisPlayer_:Number = 0; protected var rotate_:Number = 0; protected var relMoveVec_:Point = null; protected var moveMultiplier_:Number = 1; public var attackPeriod_:Number = 0; public var attackAmount_:int = 0; public var isDazed_:Boolean = false; public var isBerserk_:Boolean = false; public var minAttackFrequency_:Number = 0; public var maxAttackFrequency_:Number = 0; public var weaponRateOfFire_:Number = 0; public var nextAltAttack_:int = 0; public var nextTeleportAt_:int = 0; public var dropBoost:int = 0; public var tierBoost:int = 0; protected var healingEffect_:HealingEffect = null; protected var nearestMerchant_:Merchant = null; public var isDefaultAnimatedChar:Boolean = true; public var projectileIdSetOverrideNew:String = """"; public var projectileIdSetOverrideOld:String = """"; private var addTextLine:AddTextLineSignal; private var factory:CharacterFactory; private var ip_:IntPoint; private var breathBackFill_:GraphicsSolidFill = null; private var breathBackPath_:GraphicsPath = null; private var breathFill_:GraphicsSolidFill = null; private var breathPath_:GraphicsPath = null; private var hallucinatingMaskedImage_:MaskedImage = null; private var slideVec_:Vector3D; public function Player(_arg1:XML) { this.minAttackFrequency_ = 0.0015; this.maxAttackFrequency_ = 0.008; this.ip_ = new IntPoint(); var _local2:Injector = StaticInjectorContext.getInjector(); this.addTextLine = _local2.getInstance(AddTextLineSignal); this.factory = _local2.getInstance(CharacterFactory); super(_arg1); this.attackMax_ = int(_arg1.Attack.@max); this.defenseMax_ = int(_arg1.Defense.@max); this.speedMax_ = int(_arg1.Speed.@max); this.dexterityMax_ = int(_arg1.Dexterity.@max); this.vitalityMax_ = int(_arg1.HpRegen.@max); this.wisdomMax_ = int(_arg1.MpRegen.@max); this.maxHPMax_ = int(_arg1.MaxHitPoints.@max); this.maxMPMax_ = int(_arg1.MaxMagicPoints.@max); texturingCache_ = new Dictionary(); this.slideVec_ = new Vector3D(); } public static function fromPlayerXML(name:String, playerXML:XML):Player { var _local3:int = int(playerXML.ObjectType); var _local4:XML = ObjectLibrary.xmlLibrary_[_local3]; var _local5:Player = new Player(_local4); _local5.name_ = name; _local5.level_ = int(playerXML.Level); _local5.exp_ = Number(playerXML.Exp); _local5.equipment_ = ConversionUtil.toIntVector(playerXML.Equipment); _local5.calculateStatBoosts(); _local5.lockedSlot = new Vector.(_local5.equipment_.length); _local5.maxHP_ = (Parameters.parse(_local5.maxHPBoost_) + int(playerXML.MaxHitPoints)); _local5.hp_ = int(playerXML.HitPoints); _local5.maxMP_ = (Parameters.parse(_local5.maxMPBoost_) + int(playerXML.MaxMagicPoints)); _local5.mp_ = int(playerXML.MagicPoints); _local5.attack_ = (Parameters.parse(_local5.attackBoost_) + int(playerXML.Attack)).toString(); _local5.defense_ = (Parameters.parse(_local5.defenseBoost_) + int(playerXML.Defense)).toString(); _local5.speed_ = (Parameters.parse(_local5.speedBoost_) + int(playerXML.Speed)).toString(); _local5.dexterity_ = (Parameters.parse(_local5.vitalityBoost_) + int(playerXML.Dexterity)).toString(); _local5.vitality_ = (Parameters.parse(_local5.wisdomBoost_) + int(playerXML.HpRegen)).toString(); _local5.wisdom_ = (Parameters.parse(_local5.dexterityBoost_) + int(playerXML.MpRegen)).toString(); _local5.tex1Id_ = int(playerXML.Tex1); _local5.tex2Id_ = int(playerXML.Tex2); _local5.hasBackpack_ = int(playerXML.HasBackpack) != 0; return (_local5); } public function calculateStatBoosts():void { var _local2:int; var _local3:XML; var _local4:XML; var _local5:int; var _local6:int; this.maxHPBoost_ = ""0""; this.maxMPBoost_ = ""0""; this.attackBoost_ = ""0""; this.defenseBoost_ = ""0""; this.speedBoost_ = ""0""; this.vitalityBoost_ = ""0""; this.wisdomBoost_ = ""0""; this.dexterityBoost_ = ""0""; var _local1:uint; while (_local1 < GeneralConstants.NUM_EQUIPMENT_SLOTS) { if (((equipment_) && ((equipment_.length > _local1)))) { _local2 = equipment_[_local1]; if (_local2 != -1) { _local3 = ObjectLibrary.xmlLibrary_[_local2]; if (((!((_local3 == null))) && (_local3.hasOwnProperty(""ActivateOnEquip"")))) { for each (_local4 in _local3.ActivateOnEquip) { if (_local4.toString() == ""IncrementStat"") { _local5 = int(_local4.@stat); _local6 = int(_local4.@amount); switch (_local5) { case StatData.MAX_HP_STAT: this.maxHPBoost_ = (this.maxHPBoost_ + _local6); break; case StatData.MAX_MP_STAT: this.maxMPBoost_ = (this.maxMPBoost_ + _local6); break; case StatData.ATTACK_STAT: this.attackBoost_ = (Parameters.parse(this.attackBoost_) + _local6).toString(); break; case StatData.DEFENSE_STAT: this.defenseBoost_ = (Parameters.parse(this.defenseBoost_) + _local6).toString(); break; case StatData.SPEED_STAT: this.speedBoost_ = (Parameters.parse(this.speedBoost_) + _local6).toString(); break; case StatData.VITALITY_STAT: this.vitalityBoost_ = (Parameters.parse(this.vitalityBoost_) + _local6).toString(); break; case StatData.WISDOM_STAT: this.wisdomBoost_ = (Parameters.parse(this.wisdomBoost_) + _local6).toString(); break; case StatData.DEXTERITY_STAT: this.dexterityBoost_ = (Parameters.parse(this.dexterityBoost_) + _local6).toString(); break; } } } } } } _local1++; } } public function setRelativeMovement(_arg1:Number, _arg2:Number, _arg3:Number):void { var _local4:Number; if (this.relMoveVec_ == null) { this.relMoveVec_ = new Point(); } this.rotate_ = _arg1; this.relMoveVec_.x = _arg2; this.relMoveVec_.y = _arg3; if (isConfused()) { _local4 = this.relMoveVec_.x; this.relMoveVec_.x = -(this.relMoveVec_.y); this.relMoveVec_.y = -(_local4); this.rotate_ = -(this.rotate_); } } public function setCredits(_arg1:int):void { this.credits_ = _arg1; } public function setTokens(_arg1:int):void { this.tokens_ = _arg1; } public function setGuildName(_arg1:String):void { var _local3:GameObject; var _local4:Player; var _local5:Boolean; this.guildName_ = _arg1; var _local2:Player = map_.player_; if (_local2 == this) { for each (_local3 in map_.goDict_) { _local4 = (_local3 as Player); if (((!((_local4 == null))) && (!((_local4 == this))))) { _local4.setGuildName(_local4.guildName_); } } } else { _local5 = ((((((!((_local2 == null))) && (!((_local2.guildName_ == null))))) && (!((_local2.guildName_ == """"))))) && ((_local2.guildName_ == this.guildName_))); if (_local5 != this.isFellowGuild_) { this.isFellowGuild_ = _local5; nameBitmapData_ = null; } } } public function isTeleportEligible(_arg1:Player):Boolean { return (!(((_arg1.isPaused()) || (_arg1.isInvisible())))); } public function msUtilTeleport():int { var _local1:int = getTimer(); return (Math.max(0, (this.nextTeleportAt_ - _local1))); } public function teleportTo(_arg1:Player):Boolean { if (isPaused()) { this.addTextLine.dispatch(this.makeErrorMessage(TextKey.PLAYER_NOTELEPORTWHILEPAUSED)); return (false); } var _local2:int = this.msUtilTeleport(); if (_local2 > 0) { this.addTextLine.dispatch(this.makeErrorMessage(TextKey.PLAYER_TELEPORT_COOLDOWN, {""seconds"": int(((_local2 / 1000) + 1))})); return (false); } if (!this.isTeleportEligible(_arg1)) { if (_arg1.isInvisible()) { this.addTextLine.dispatch(this.makeErrorMessage(TextKey.TELEPORT_INVISIBLE_PLAYER, {""player"": _arg1.name_})); } else { this.addTextLine.dispatch(this.makeErrorMessage(TextKey.PLAYER_TELEPORT_TO_PLAYER, {""player"": _arg1.name_})); } return (false); } map_.gs_.gsc_.playerText(""/teleport "" + _arg1.name_); this.nextTeleportAt_ = (getTimer() + MS_BETWEEN_TELEPORT); return (true); } private function makeErrorMessage(_arg1:String, _arg2:Object = null):ChatMessage { return (ChatMessage.make(Parameters.ERROR_CHAT_NAME, _arg1, -1, -1, """", false, _arg2)); } public function levelUpEffect(_arg1:String, _arg2:Boolean = true):void { if (_arg2) { this.levelUpParticleEffect(); } var _local3:QueuedStatusText = new QueuedStatusText(this, new LineBuilder().setParams(_arg1), 0xFF00, 2000); map_.mapOverlay_.addQueuedText(_local3); } public function handleLevelUp(_arg1:Boolean):void { SoundEffectLibrary.play(""level_up""); if (_arg1) { this.levelUpEffect(TextKey.PLAYER_NEWCLASSUNLOCKED, false); this.levelUpEffect(TextKey.PLAYER_LEVELUP); } else { this.levelUpEffect(TextKey.PLAYER_LEVELUP); } } public function levelUpParticleEffect(_arg1:uint = 0xFF00FF00):void { map_.addObj(new LevelUpEffect(this, _arg1, 20), x_, y_); } public function handleExpUp(_arg1:Number):void { var _local2:CharacterStatusText = new CharacterStatusText(this, 0xFFFFFF, 1000); _local2.setStringBuilder(new LineBuilder().setParams(TextKey.PLAYER_EXP, {""exp"": _arg1})); map_.mapOverlay_.addStatusText(_local2); } private function getNearbyMerchant():Merchant { var _local3:Point; var _local4:Merchant; var _local1:int = ((((x_ - int(x_))) > 0.5) ? 1 : -1); var _local2:int = ((((y_ - int(y_))) > 0.5) ? 1 : -1); for each (_local3 in NEARBY) { this.ip_.x_ = (x_ + (_local1 * _local3.x)); this.ip_.y_ = (y_ + (_local2 * _local3.y)); _local4 = map_.merchLookup_[this.ip_]; if (_local4 != null) { return ((((PointUtil.distanceSquaredXY(_local4.x_, _local4.y_, x_, y_) < 1)) ? _local4 : null)); } } return (null); } public function walkTo(_arg1:Number, _arg2:Number):Boolean { this.modifyMove(_arg1, _arg2, newP); return (this.moveTo(newP.x, newP.y)); } override public function moveTo(_arg1:Number, _arg2:Number):Boolean { var _local3:Boolean = super.moveTo(_arg1, _arg2); if (map_.gs_.evalIsNotInCombatMapArea()) { this.nearestMerchant_ = this.getNearbyMerchant(); } return (_local3); } public function modifyMove(_arg1:Number, _arg2:Number, _arg3:Point):void { if (((isParalyzed()) || (isPetrified()))) { _arg3.x = x_; _arg3.y = y_; return; } var _local4:Number = (_arg1 - x_); var _local5:Number = (_arg2 - y_); if ((((((((_local4 < MOVE_THRESHOLD)) && ((_local4 > -(MOVE_THRESHOLD))))) && ((_local5 < MOVE_THRESHOLD)))) && ((_local5 > -(MOVE_THRESHOLD))))) { this.modifyStep(_arg1, _arg2, _arg3); return; } var _local6:Number = (MOVE_THRESHOLD / Math.max(Math.abs(_local4), Math.abs(_local5))); var _local7:Number = 0; _arg3.x = x_; _arg3.y = y_; var _local8:Boolean; while (!(_local8)) { if ((_local7 + _local6) >= 1) { _local6 = (1 - _local7); _local8 = true; } this.modifyStep((_arg3.x + (_local4 * _local6)), (_arg3.y + (_local5 * _local6)), _arg3); _local7 = (_local7 + _local6); } } public function modifyStep(_arg1:Number, _arg2:Number, _arg3:Point):void { var _local6:Number; var _local7:Number; var _local4:Boolean = ((((((x_ % 0.5) == 0)) && (!((_arg1 == x_))))) || (!((int((x_ / 0.5)) == int((_arg1 / 0.5)))))); var _local5:Boolean = ((((((y_ % 0.5) == 0)) && (!((_arg2 == y_))))) || (!((int((y_ / 0.5)) == int((_arg2 / 0.5)))))); if (((((!(_local4)) && (!(_local5)))) || (this.isValidPosition(_arg1, _arg2)))) { _arg3.x = _arg1; _arg3.y = _arg2; return; } if (_local4) { _local6 = (((_arg1) > x_) ? (int((_arg1 * 2)) / 2) : (int((x_ * 2)) / 2)); if (int(_local6) > int(x_)) { _local6 = (_local6 - 0.01); } } if (_local5) { _local7 = (((_arg2) > y_) ? (int((_arg2 * 2)) / 2) : (int((y_ * 2)) / 2)); if (int(_local7) > int(y_)) { _local7 = (_local7 - 0.01); } } if (!_local4) { _arg3.x = _arg1; _arg3.y = _local7; if (((!((square_ == null))) && (!((square_.props_.slideAmount_ == 0))))) { this.resetMoveVector(false); } return; } if (!_local5) { _arg3.x = _local6; _arg3.y = _arg2; if (((!((square_ == null))) && (!((square_.props_.slideAmount_ == 0))))) { this.resetMoveVector(true); } return; } var _local8:Number = (((_arg1) > x_) ? (_arg1 - _local6) : (_local6 - _arg1)); var _local9:Number = (((_arg2) > y_) ? (_arg2 - _local7) : (_local7 - _arg2)); if (_local8 > _local9) { if (this.isValidPosition(_arg1, _local7)) { _arg3.x = _arg1; _arg3.y = _local7; return; } if (this.isValidPosition(_local6, _arg2)) { _arg3.x = _local6; _arg3.y = _arg2; return; } } else { if (this.isValidPosition(_local6, _arg2)) { _arg3.x = _local6; _arg3.y = _arg2; return; } if (this.isValidPosition(_arg1, _local7)) { _arg3.x = _arg1; _arg3.y = _local7; return; } } _arg3.x = _local6; _arg3.y = _local7; } private function resetMoveVector(_arg1:Boolean):void { moveVec_.scaleBy(-0.5); if (_arg1) { moveVec_.y = (moveVec_.y * -1); } else { moveVec_.x = (moveVec_.x * -1); } } public function isValidPosition(_arg1:Number, _arg2:Number):Boolean { var _local3:Square = map_.getSquare(_arg1, _arg2); if (((!((square_ == _local3))) && ((((_local3 == null)) || (!(_local3.isWalkable())))))) { return (false); } var _local4:Number = (_arg1 - int(_arg1)); var _local5:Number = (_arg2 - int(_arg2)); if (_local4 < 0.5) { if (this.isFullOccupy((_arg1 - 1), _arg2)) { return (false); } if (_local5 < 0.5) { if (((this.isFullOccupy(_arg1, (_arg2 - 1))) || (this.isFullOccupy((_arg1 - 1), (_arg2 - 1))))) { return (false); } } else { if (_local5 > 0.5) { if (((this.isFullOccupy(_arg1, (_arg2 + 1))) || (this.isFullOccupy((_arg1 - 1), (_arg2 + 1))))) { return (false); } } } } else { if (_local4 > 0.5) { if (this.isFullOccupy((_arg1 + 1), _arg2)) { return (false); } if (_local5 < 0.5) { if (((this.isFullOccupy(_arg1, (_arg2 - 1))) || (this.isFullOccupy((_arg1 + 1), (_arg2 - 1))))) { return (false); } } else { if (_local5 > 0.5) { if (((this.isFullOccupy(_arg1, (_arg2 + 1))) || (this.isFullOccupy((_arg1 + 1), (_arg2 + 1))))) { return (false); } } } } else { if (_local5 < 0.5) { if (this.isFullOccupy(_arg1, (_arg2 - 1))) { return (false); } } else { if (_local5 > 0.5) { if (this.isFullOccupy(_arg1, (_arg2 + 1))) { return (false); } } } } } return (true); } public function isFullOccupy(_arg1:Number, _arg2:Number):Boolean { var _local3:Square = map_.lookupSquare(_arg1, _arg2); return ((((((_local3 == null)) || ((_local3.tileType_ == 0xFF)))) || (((!((_local3.obj_ == null))) && (_local3.obj_.props_.fullOccupy_))))); } override public function update(currentTime:int, deltaMS:int):Boolean { if (this.tierBoost && !isPaused()) { this.tierBoost = this.tierBoost - deltaMS; if (this.tierBoost < 0) { this.tierBoost = 0; } } if (this.dropBoost && !isPaused()) { this.dropBoost = this.dropBoost - deltaMS; if (this.dropBoost < 0) { this.dropBoost = 0; } } if (this.xpTimer && !isPaused()) { this.xpTimer = this.xpTimer - deltaMS; if (this.xpTimer < 0) { this.xpTimer = 0; } } if (isHealing() && !isPaused()) { if (this.healingEffect_ == null) { this.healingEffect_ = new HealingEffect(this); map_.addObj(this.healingEffect_, x_, y_); } } else { if (this.healingEffect_ != null) { map_.removeObj(this.healingEffect_.objectId_); this.healingEffect_ = null; } } var angle:Number = Parameters.data_.cameraAngle; if (this.rotate_ != 0) { angle = angle + deltaMS * Parameters.PLAYER_ROTATE_SPEED * this.rotate_; Parameters.data_.cameraAngle = angle; } if (map_.player_ == this && isPaused()) { return true; } if (this.relMoveVec_ != null) { if (this.relMoveVec_.x != 0 || this.relMoveVec_.y != 0) { var mvSpd:Number = this.getMoveSpeed(); var mvAngle:Number = Math.atan2(this.relMoveVec_.y, this.relMoveVec_.x); if (square_.props_.slideAmount_ > 0) { slideVec_.x = mvSpd * Math.cos(angle + mvAngle); slideVec_.y = mvSpd * Math.sin(angle + mvAngle); slideVec_.z = 0; moveVec_.scaleBy(square_.props_.slideAmount_); if (moveVec_.length < slideVec_.length) { slideVec_.scaleBy(1 - square_.props_.slideAmount_); moveVec_ = moveVec_.add(slideVec_); } } else { moveVec_.x = mvSpd * Math.cos(angle + mvAngle); moveVec_.y = mvSpd * Math.sin(angle + mvAngle); } } else { if (moveVec_.length > 0.00012 && square_.props_.slideAmount_ > 0) { moveVec_.scaleBy(square_.props_.slideAmount_); } else { moveVec_.x = 0; moveVec_.y = 0; } } if (square_ != null && square_.props_.push_) { moveVec_.x = moveVec_.x - square_.props_.animate_.dx_ / 1000; moveVec_.y = moveVec_.y - square_.props_.animate_.dy_ / 1000; } this.walkTo(x_ + deltaMS * moveVec_.x, y_ + deltaMS * moveVec_.y); } else { if (!super.update(currentTime, deltaMS)) { return false; } } if (map_.player_ == this && square_.props_.maxDamage_ > 0 && (square_.lastDamage_ + 500) < currentTime && !isInvincible() && (square_.obj_ == null || !square_.obj_.props_.protectFromGroundDamage_)) { var dmg:int = map_.gs_.gsc_.getNextDamage(square_.props_.minDamage_, square_.props_.maxDamage_); var conditionEffects:Vector. = new Vector.(); conditionEffects.push(ConditionEffect.GROUND_DAMAGE); damage(-1, dmg, conditionEffects, hp_ <= dmg, null); map_.gs_.gsc_.groundDamage(currentTime, x_, y_); square_.lastDamage_ = currentTime; } return true; } public function onMove():void { if (map_ == null) { return; } var _local1:Square = map_.getSquare(x_, y_); if (_local1.props_.sinking_) { sinkLevel_ = Math.min((sinkLevel_ + 1), Parameters.MAX_SINK_LEVEL); this.moveMultiplier_ = (0.1 + ((1 - (sinkLevel_ / Parameters.MAX_SINK_LEVEL)) * (_local1.props_.speed_ - 0.1))); } else { sinkLevel_ = 0; this.moveMultiplier_ = _local1.props_.speed_; } } override protected function makeNameBitmapData():BitmapData { var _local1:StringBuilder = new StaticStringBuilder(name_); var _local2:BitmapTextFactory = StaticInjectorContext.getInjector().getInstance(BitmapTextFactory); var _local3:BitmapData = _local2.make(_local1, 16, this.getNameColor(), true, NAME_OFFSET_MATRIX, true); _local3.draw(FameUtil.numStarsToIcon(this.numStars_), RANK_OFFSET_MATRIX); return (_local3); } private function getNameColor():uint { if (this.isFellowGuild_) { return (Parameters.FELLOW_GUILD_COLOR); } if (this.nameChosen_) { return (Parameters.NAME_CHOSEN_COLOR); } return (0xFFFFFF); } protected function drawBreathBar(_arg1:Vector., _arg2:int):void { var _local7:Number; var _local8:Number; if (this.breathPath_ == null) { this.breathBackFill_ = new GraphicsSolidFill(); this.breathBackPath_ = new GraphicsPath(GraphicsUtil.QUAD_COMMANDS, new Vector.()); this.breathFill_ = new GraphicsSolidFill(2542335); this.breathPath_ = new GraphicsPath(GraphicsUtil.QUAD_COMMANDS, new Vector.()); } if (this.breath_ <= Parameters.BREATH_THRESH) { _local7 = ((Parameters.BREATH_THRESH - this.breath_) / Parameters.BREATH_THRESH); this.breathBackFill_.color = MoreColorUtil.lerpColor(0x545454, 0xFF0000, (Math.abs(Math.sin((_arg2 / 300))) * _local7)); } else { this.breathBackFill_.color = 0x545454; } var _local3:int = 20; var _local4:int = 8; var _local5:int = 6; var _local6:Vector. = (this.breathBackPath_.data as Vector.); _local6.length = 0; _local6.push((posS_[0] - _local3), (posS_[1] + _local4), (posS_[0] + _local3), (posS_[1] + _local4), (posS_[0] + _local3), ((posS_[1] + _local4) + _local5), (posS_[0] - _local3), ((posS_[1] + _local4) + _local5)); _arg1.push(this.breathBackFill_); _arg1.push(this.breathBackPath_); _arg1.push(GraphicsUtil.END_FILL); if (this.breath_ > 0) { _local8 = (((this.breath_ / 100) * 2) * _local3); this.breathPath_.data.length = 0; _local6 = (this.breathPath_.data as Vector.); _local6.length = 0; _local6.push((posS_[0] - _local3), (posS_[1] + _local4), ((posS_[0] - _local3) + _local8), (posS_[1] + _local4), ((posS_[0] - _local3) + _local8), ((posS_[1] + _local4) + _local5), (posS_[0] - _local3), ((posS_[1] + _local4) + _local5)); _arg1.push(this.breathFill_); _arg1.push(this.breathPath_); _arg1.push(GraphicsUtil.END_FILL); } GraphicsFillExtra.setSoftwareDrawSolid(this.breathFill_, true); GraphicsFillExtra.setSoftwareDrawSolid(this.breathBackFill_, true); } override public function draw(_arg1:Vector., _arg2:Camera, _arg3:int):void { if (this != map_.player_) { if(Parameters.data_.hidePlayers){ return; } if (!Parameters.screenShotMode_) { drawName(_arg1, _arg2); } } else { if (this.breath_ >= 0) { this.drawBreathBar(_arg1, _arg3); } } super.draw(_arg1, _arg2, _arg3); } private function getMoveSpeed():Number { if (isSlowed()) { return ((MIN_MOVE_SPEED * this.moveMultiplier_)); } var _local1:Number = (MIN_MOVE_SPEED + ((Parameters.parse(this.speed_) / 75) * (MAX_MOVE_SPEED - MIN_MOVE_SPEED))); if (((isSpeedy()) || (isNinjaSpeedy()))) { _local1 = (_local1 * 1.5); } return ((_local1 * this.moveMultiplier_)); } public function attackFrequency():Number { this.isDazed_ = isDazed(); this.isBerserk_ = isBerserk(); if (this.isDazed_) return this.minAttackFrequency_; var _rateOfFire:Number = this.minAttackFrequency_ + ((Parameters.parse(this.dexterity_) / 75) * (this.maxAttackFrequency_ - this.minAttackFrequency_)); if (this.isBerserk_) _rateOfFire *= 1.5; return (_rateOfFire); } private function attackMultiplier():Number { if (isWeak()) { return (MIN_ATTACK_MULT); } var _local1:Number = (MIN_ATTACK_MULT + (((this.attackLevel_ + Parameters.parse(this.attackBoost_)) / 75) * (MAX_ATTACK_MULT - MIN_ATTACK_MULT))); if (isDamaging()) { _local1 = (_local1 * 1.5); } return (_local1); } private function makeSkinTexture():void { var _local1:MaskedImage = this.skin.imageFromAngle(0, AnimatedChar.STAND, 0); animatedChar_ = this.skin; texture_ = _local1.image_; mask_ = _local1.mask_; this.isDefaultAnimatedChar = true; } private function setToRandomAnimatedCharacter():void { var _local1:Vector. = ObjectLibrary.hexTransforms_; var _local2:uint = Math.floor((Math.random() * _local1.length)); var _local3:int = _local1[_local2].@type; var _local4:TextureData = ObjectLibrary.typeToTextureData_[_local3]; texture_ = _local4.texture_; mask_ = _local4.mask_; animatedChar_ = _local4.animatedChar_; this.isDefaultAnimatedChar = false; } override protected function getTexture(camera:Camera, currentTime:int):BitmapData { var pos:Number = 0; var action:int = AnimatedChar.STAND; if (this.isShooting || currentTime < (attackStart_ + this.attackPeriod_)) { facing_ = attackAngle_; pos = ((currentTime - attackStart_) % this.attackPeriod_) / this.attackPeriod_; action = AnimatedChar.ATTACK; } else { if (moveVec_.x != 0 || moveVec_.y != 0) { var movPeriod:int = 3.5 / this.getMoveSpeed(); if (moveVec_.y != 0 || moveVec_.x != 0) { facing_ = Math.atan2(moveVec_.y, moveVec_.x); } pos = (currentTime % movPeriod) / movPeriod; action = AnimatedChar.WALK; } } if (this.isHexed()) { this.isDefaultAnimatedChar && this.setToRandomAnimatedCharacter(); } else { if (!this.isDefaultAnimatedChar) { this.makeSkinTexture(); } } var maskImg:MaskedImage; if (camera.isHallucinating_) { maskImg = getHallucinatingMaskedImage(); } else { maskImg = animatedChar_.imageFromFacing(facing_, camera, action, pos); } var tex1Id:int = tex1Id_; var tex2Id:int = tex2Id_; var tex:BitmapData; if (this.nearestMerchant_) { var merchDict:Dictionary = texturingCache_[this.nearestMerchant_]; if (merchDict == null) { texturingCache_[this.nearestMerchant_] = new Dictionary(); } else { tex = merchDict[maskImg]; } tex1Id = this.nearestMerchant_.getTex1Id(tex1Id_); tex2Id = this.nearestMerchant_.getTex2Id(tex2Id_); } else { tex = texturingCache_[maskImg]; } if (tex == null) { tex = TextureRedrawer.resize(maskImg.image_, maskImg.mask_, size_, false, tex1Id, tex2Id); if (this.nearestMerchant_ != null) { texturingCache_[this.nearestMerchant_][maskImg] = tex; } else { texturingCache_[maskImg] = tex; } } if (hp_ < maxHP_ * 0.2) { var intensity:Number = int(Math.abs(Math.sin(currentTime / 200)) * 10) / 10; var ct:ColorTransform = lowHealthCT[intensity]; if (ct == null) { ct = new ColorTransform(1, 1, 1, 1, intensity * LOW_HEALTH_CT_OFFSET, -intensity * LOW_HEALTH_CT_OFFSET, -intensity * LOW_HEALTH_CT_OFFSET); lowHealthCT[intensity] = ct; } tex = CachingColorTransformer.transformBitmapData(tex, ct); } var plrTex:BitmapData = texturingCache_[tex]; if (plrTex == null) { plrTex = GlowRedrawer.outlineGlowPlayer(tex, this.glowColor_); texturingCache_[tex] = plrTex; } if (isPaused() || isStasis() || isPetrified()) { plrTex = CachingColorTransformer.filterBitmapData(plrTex, PAUSED_FILTER); } else { if (isInvisible()) { plrTex = CachingColorTransformer.alphaBitmapData(plrTex, 40); } } return plrTex; } private function getHallucinatingMaskedImage():MaskedImage { if (hallucinatingMaskedImage_ == null) { hallucinatingMaskedImage_ = new MaskedImage(getHallucinatingTexture(), null); } return hallucinatingMaskedImage_; } override public function getPortrait():BitmapData { var _local1:MaskedImage; var _local2:int; if (portrait_ == null) { _local1 = animatedChar_.imageFromDir(AnimatedChar.RIGHT, AnimatedChar.STAND, 0); _local2 = ((4 / _local1.image_.width) * 100); portrait_ = TextureRedrawer.resize(_local1.image_, _local1.mask_, _local2, true, tex1Id_, tex2Id_); portrait_ = GlowRedrawer.outlineGlow(portrait_, 0); } return (portrait_); } public function useAltWeapon(_arg1:Number, _arg2:Number, _arg3:int):Boolean { var _local7:XML; var _local8:int; var _local9:Number; var _local10:int; var _local11:int; var _local12:Boolean; if ((((map_ == null)) || (isPaused()))) { return (false); } var _local4:int = equipment_[1]; if (_local4 == -1) { return (false); } var _local5:XML = ObjectLibrary.xmlLibrary_[_local4]; if ((((_local5 == null)) || (!(_local5.hasOwnProperty(""Usable""))))) { return (false); } var _local6:Point = map_.pSTopW(_arg1, _arg2); if (_local6 == null) { SoundEffectLibrary.play(""error""); return (false); } for each (_local7 in _local5.Activate) { if (_local7.toString() == ActivationType.TELEPORT) { if (!this.isValidPosition(_local6.x, _local6.y)) { SoundEffectLibrary.play(""error""); return (false); } } } _local8 = getTimer(); if (_arg3 == UseType.START_USE) { if (_local8 < this.nextAltAttack_) { SoundEffectLibrary.play(""error""); return (false); } _local10 = int(_local5.MpCost); if (_local10 > this.mp_) { SoundEffectLibrary.play(""no_mana""); return (false); } _local11 = 2000; if (_local5.hasOwnProperty(TextKey.COOLDOWN)) { _local11 = (Number(_local5.Cooldown) * NumberKey.COOLDOWNVALUE); } this.nextAltAttack_ = (_local8 + _local11); map_.gs_.gsc_.useItem(_local8, objectId_, 1, _local4, _local6.x, _local6.y, _arg3, isTrading); } else { if (_local5.hasOwnProperty(""MultiPhase"")) { map_.gs_.gsc_.useItem(_local8, objectId_, 1, _local4, _local6.x, _local6.y, _arg3, isTrading); _local10 = int(_local5.MpEndCost); if (_local10 <= this.mp_) { _local9 = Math.atan2(_arg2, _arg1); this.doShoot(_local4, _local5, (Parameters.data_.cameraAngle + _local9), false, false); } } } return (true); } public function attemptAttackAngle(_arg1:Number):void { this.shoot((Parameters.data_.cameraAngle + _arg1)); } override public function setAttack(_arg1:int, _arg2:Number):void { var _local3:XML = ObjectLibrary.xmlLibrary_[_arg1]; if ((((_local3 == null)) || (!(_local3.hasOwnProperty(TextKey.RATEOFFIRE))))) { return; } var _local4:Number = Number(_local3.RateOfFire); this.attackPeriod_ = ((NumberKey.RATEOFFIREVALUE / this.attackFrequency()) * (NumberKey.RATEOFFIREVALUE / _local4)); super.setAttack(_arg1, _arg2); } private function shoot(angle:Number):void { if (map_ == null || isStunned() || isPaused() || isPetrified()) return; var weapType:int = this.equipment_[0]; if (weapType == -1) return; var weapon:XML = ObjectLibrary.xmlLibrary_[weapType]; var curTime:int = getTimer(); this.weaponRateOfFire_ = Number(weapon.RateOfFire); this.attackPeriod_ = (NumberKey.RATEOFFIREVALUE / this.attackFrequency()) * (NumberKey.RATEOFFIREVALUE / this.weaponRateOfFire_); if (curTime < this.attackStart_ + this.attackPeriod_) return; doneAction(map_.gs_, Tutorial.ATTACK_ACTION); this.attackAngle_ = angle; this.attackStart_ = curTime; this.doShoot(weapType, weapon, attackAngle_, true, false); } private function doShoot(weaponType:int, weaponXML:XML, attackAngle:Number, isShooting:Boolean, isAbility:Boolean):void { var _local11:uint; var _local12:Projectile; var _local13:int; var _local14:int; var _local15:Number; var _local16:int; var arcGap:Number = (weaponXML.hasOwnProperty(TextKey.ARCGAP) ? Number(weaponXML.ArcGap) : NumberKey.ARCGAPVALUE) * Trig.toRadians; var _local8:Number = (arcGap * (this.attackAmount_ - 1)); var _local9:Number = (attackAngle - (_local8 / 2)); this.isShooting = isShooting; this.attackAmount_ = weaponXML.hasOwnProperty(TextKey.NUMPROJECTILES) ? int(weaponXML.NumProjectiles) : NumberKey.NUMPROJECTILESVALUE; var _local10:int; while (_local10 < this.attackAmount_) { _local11 = getBulletId(); _local12 = (FreeList.newObject(Projectile) as Projectile); if (((isShooting) && (!((this.projectileIdSetOverrideNew == """"))))) { _local12.reset(weaponType, 0, objectId_, _local11, _local9, this.attackStart_, this.projectileIdSetOverrideNew, this.projectileIdSetOverrideOld); } else { _local12.reset(weaponType, 0, objectId_, _local11, _local9, this.attackStart_); } _local13 = int(_local12.projProps_.minDamage_); _local14 = int(_local12.projProps_.maxDamage_); _local15 = ((isShooting) ? this.attackMultiplier() : 1); _local16 = (map_.gs_.gsc_.getNextDamage(_local13, _local14) * _local15); _local12.setDamage(_local16); if ((((_local10 == 0)) && (!((_local12.sound_ == null))))) { SoundEffectLibrary.play(_local12.sound_, 0.75, false); } map_.addObj(_local12, (x_ + (Math.cos(attackAngle) * 0.3)), (y_ + (Math.sin(attackAngle) * 0.3))); map_.gs_.gsc_.playerShoot(_local12, this.attackAmount_, this.isDazed_, this.isBerserk_, this.minAttackFrequency_, this.maxAttackFrequency_, this.weaponRateOfFire_, isAbility); _local9 = (_local9 + arcGap); _local10++; } } public function isHexed():Boolean { return (!(((condition_[ConditionEffect.CE_FIRST_BATCH] & ConditionEffect.HEXED_BIT) == 0))); } public function isInventoryFull():Boolean { if (equipment_ == null) { return (false); } var _local1:int = equipment_.length; var _local2:uint = 4; while (_local2 < _local1) { if (equipment_[_local2] <= 0) { return (false); } _local2++; } return (true); } public function nextAvailableInventorySlot():int { var _local1:int = ((this.hasBackpack_) ? equipment_.length : (equipment_.length - GeneralConstants.NUM_INVENTORY_SLOTS)); var _local2:uint = 4; while (_local2 < _local1) { if (equipment_[_local2] <= 0) { return (_local2); } _local2++; } return (-1); } public function numberOfAvailableSlots():int { var _local1:int = ((this.hasBackpack_) ? equipment_.length : (equipment_.length - GeneralConstants.NUM_INVENTORY_SLOTS)); var _local2:int; var _local3:uint = 4; while (_local3 < _local1) { if (equipment_[_local3] <= 0) { _local2++; } _local3++; } return (_local2); } public function swapInventoryIndex(_arg1:String):int { var _local2:int; var _local3:int; if (!this.hasBackpack_) { return (-1); } if (_arg1 == TabStripModel.BACKPACK) { _local2 = GeneralConstants.NUM_EQUIPMENT_SLOTS; _local3 = (GeneralConstants.NUM_EQUIPMENT_SLOTS + GeneralConstants.NUM_INVENTORY_SLOTS); } else { _local2 = (GeneralConstants.NUM_EQUIPMENT_SLOTS + GeneralConstants.NUM_INVENTORY_SLOTS); _local3 = equipment_.length; } var _local4:uint = _local2; while (_local4 < _local3) { if (equipment_[_local4] <= 0) { return (_local4); } _local4++; } return (-1); } public function getPotionCount(_arg1:int):int { switch (_arg1) { case PotionInventoryModel.HEALTH_POTION_ID: return (this.healthPotionCount_); case PotionInventoryModel.MAGIC_POTION_ID: return (this.magicPotionCount_); } return (0); } public function getTex1():int { return (tex1Id_); } public function getTex2():int { return (tex2Id_); } } } ",12139,False,2119.7887099100762,median "#include #include #include #include #include String CommOut=""""; String CommIn=""""; String lastComm = """"; int StepSpeed = 50; int lastSpeed = 50; int SMov[32]={1440,1440,1440,0,1440,1440,1440,0,0,0,0,0,1440,1440,1440,0,1440,1440,1440,0,0,0,0,0,1440,1440,1440,0,1440,1440,1440,0}; int SAdj[32]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; int StaBlink=0; int IntBlink=0; int ClawPos=1500; //SSID and Password to your ESP Access Point const char* ssid = ""HexapodWifi""; const char* password = ""12345678""; static const char PROGMEM INDEX_HTML[] = R""rawliteral( ESP8266 Spider Hexapod  
Quadruped Controller
 
 
 

this application requires Mwilmar Quadruped platform.

)rawliteral""; WebSocketsServer webSocket = WebSocketsServer(81); ESP8266WebServer server(80); void setup() { pinMode(LED_BUILTIN, OUTPUT); Serial.begin(115200); Serial.println ("">> Setup""); for(uint8_t t = 4;t > 0;t--) { Serial.flush(); delay(1000); } delay(1000); WiFi.mode(WIFI_AP); //Only Access point WiFi.softAP(ssid, password); //Start HOTspot removing password will disable security IPAddress myIP = WiFi.softAPIP(); //Get IP address Serial.println(""""); Serial.print(""Connected to ""); Serial.println(ssid); Serial.print(""IP address: ""); Serial.println(myIP); server.on(""/"", [](){ server.send(200, ""text/html"", INDEX_HTML); }); server.begin(); webSocket.begin(); webSocket.onEvent(webSocketEvent); } void loop() { if (Serial.available() > 0){ char c[] = {(char)Serial.read()}; webSocket.broadcastTXT(c, sizeof(c)); } IntBlink +=1; if (IntBlink >=5000){ if (StaBlink ==0){ digitalWrite(LED_BUILTIN, HIGH); StaBlink=1; } else { digitalWrite(LED_BUILTIN, LOW); StaBlink=0; } IntBlink =0; } webSocket.loop(); server.handleClient(); if (CommOut == ""w 0 1"") Move_STP(); //~~~~~~~~ Stop if (CommOut == ""w 1 1"") Move_FWD(); //~~~~~~~~ Forward if (CommOut == ""w 2 1"") Move_BWD(); //~~~~~~~~ backward if (CommOut == ""w 3 1"") Move_LFT(); //~~~~~~~~ turn left if (CommOut == ""w 4 1"") Move_RGT(); //~~~~~~~~ turn right //~~~~~~~~ shake hand if (CommOut == ""w 5 3""){ lastSpeed = StepSpeed;StepSpeed = 300; Move_SHK();StepSpeed = lastSpeed;CommOut=lastComm; } //~~~~~~~~ waving if (CommOut == ""w 6 3""){ lastSpeed = StepSpeed;StepSpeed = 300; Move_WAV();StepSpeed = lastSpeed;CommOut=lastComm; } //~~~~~~~~ pos initial if (CommOut == ""w 15"") { Pos_INT();CommOut=lastComm; } //~~~~~~~~ pos service if (CommOut == ""w 12"") { Pos_SRV();CommOut=lastComm; } //~~~~~~~~ adjust body left if (CommOut == ""w 11 5"") { Adj_LF();CommOut=lastComm; } //~~~~~~~~ adjust body right if (CommOut == ""w 10 5"") { Adj_RG();CommOut=lastComm; } //~~~~~~~~ adjust head up if (CommOut == ""w 8 5"") { Adj_HU();CommOut=lastComm; } //~~~~~~~~ adjust head down if (CommOut == ""w 9 5"") { Adj_HD();CommOut=lastComm; } //~~~~~~~~ adjust body higher if (CommOut == ""w 13"") { Adj_HG();CommOut=lastComm; } //~~~~~~~~ adjust body lower if (CommOut == ""w 14"") { Adj_LW();CommOut=lastComm; } //~~~~~~~~ adjust twist left if (CommOut == ""w 16"") { Adj_TL();CommOut=lastComm; } //~~~~~~~~ adjust twist right if (CommOut == ""w 17"") { Adj_TR();CommOut=lastComm; } //~~~~~~~~ adjust speed walk if (CommOut == ""w 0 0"") { StepSpeed = 300;CommOut=lastComm; } //~~~~~~~~ adjust speed run if (CommOut == ""w 7 1"") { StepSpeed = 50;CommOut=lastComm; } //~~~~~~~ claw close if (CommOut == ""w 20"") { ClwCls();CommOut=lastComm; } //~~~~~~~~~~~ claw open if (CommOut == ""w 21"") { ClwOpn();CommOut=lastComm; } } void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) { switch(type) { case WStype_DISCONNECTED: break; case WStype_CONNECTED: { IPAddress ip = webSocket.remoteIP(num); } break; case WStype_TEXT: lastComm = CommOut; CommOut = """"; for(int i = 0;i < length;i++) CommOut += ((char) payload[i]); // send data to all connected clients webSocket.broadcastTXT(payload, length); break; case WStype_BIN: hexdump(payload, length); // echo data back to browser webSocket.sendBIN(num, payload, length); break;default:break; } } void Send_Comm() { String SendString;int i; for (i = 1;i < 32;i += 1) { if (SMov[i]>=600 and SMov[i]<=2280){ SendString = SendString +""#"" +i +""P"" +String(SMov[i]); } } Serial.print (SendString +""T""+String(StepSpeed)+""D0\\r\\n"");wait_serial_return_ok(); } void wait_serial_return_ok() { // int TimeOut=0; int num=0; char c[16]; while(1) { // TimeOut +=1; while(Serial.available() > 0) { webSocket.loop();server.handleClient(); c[num]=Serial.read();num++; if(num>=15) num=0; } if(c[num-2]=='O'&&c[num-1]=='K') break; // if(TimeOut > 800000) break; } } //================================================================================= Servo Move ======================================================================= //~~~~~~~~ claw open void ClwOpn(){ ClawPos=1000; if (ClawPos <= 1000) ClawPos=1000; Serial.println(""#9P"" + String(ClawPos) + ""T50D0""); wait_serial_return_ok(); } //~~~~~~~~~~claw close void ClwCls(){ ClawPos +=100; if (ClawPos >= 1600) ClawPos=1600; Serial.println(""#9P"" + String(ClawPos) + ""T50D0""); wait_serial_return_ok(); } //~~~~~~~~ Service position void Pos_SRV(){ lastSpeed = StepSpeed;StepSpeed = 50; SMov[29]=SAdj[29]+1440;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1440;SMov[17]=SAdj[17]+1440;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1440;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1440;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1440;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1440;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1440;Send_Comm(); StepSpeed = lastSpeed; } //~~~~~~~~ Initial position (adjust all init servo here) void Pos_INT(){ SAdj[29]=0;SAdj[30]=0;SAdj[31]=0;SAdj[17]=0;SAdj[18]=0;SAdj[19]=0;SAdj[1]=0;SAdj[2]=0;SAdj[3]=0;SAdj[5]=0;SAdj[6]=0;SAdj[7]=0;SAdj[13]=0;SAdj[14]=0;SAdj[15]=0;SAdj[25]=0;SAdj[26]=0;SAdj[27]=0;Send_Comm(); Pos_SRV(); } //~~~~~~~~ Stop motion void Move_STP(){ SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1440;Send_Comm(); } //~~~~~~~~ Shake hand void Move_SHK(){ SMov[5]=SAdj[5]+1117;SMov[6]=SAdj[6]+2218;SMov[7]=SAdj[7]+1828;Send_Comm(); SMov[7]=SAdj[7]+1246;Send_Comm(); SMov[7]=SAdj[7]+1795;Send_Comm(); SMov[7]=SAdj[7]+1182;Send_Comm(); SMov[7]=SAdj[7]+1763;Send_Comm(); SMov[7]=SAdj[7]+1117;Send_Comm(); SMov[5]=SAdj[5]+1440;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;Send_Comm(); } //~~~~~~~~ Waving hand void Move_WAV(){ SMov[5]=SAdj[5]+1058;SMov[6]=SAdj[6]+1975;SMov[7]=SAdj[7]+2280;Send_Comm(); SMov[5]=SAdj[5]+1478;Send_Comm(); SMov[5]=SAdj[5]+1096;Send_Comm(); SMov[5]=SAdj[5]+1478;Send_Comm(); SMov[5]=SAdj[5]+1096;Send_Comm(); SMov[5]=SAdj[5]+1478;Send_Comm(); SMov[5]=SAdj[5]+1440;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;Send_Comm(); } //~~~~~~~~ adjust body higher void Adj_HG(){ SAdj[6]-=50;SAdj[7]+=25;SAdj[14]-=50;SAdj[15]+=25;SAdj[26]-=50;SAdj[27]+=25;SAdj[2]+=50;SAdj[3]-=25;SAdj[18]+=50;SAdj[19]-=25;SAdj[30]+=50;SAdj[31]-=25; Pos_SRV(); } //~~~~~~~~ adjust body lower void Adj_LW(){ SAdj[6]+=50;SAdj[7]-=25;SAdj[14]+=50;SAdj[15]-=25;SAdj[26]+=50;SAdj[27]-=25;SAdj[2]-=50;SAdj[3]+=25;SAdj[18]-=50;SAdj[19]+=25;SAdj[30]-=50;SAdj[31]+=25; Pos_SRV(); } //~~~~~~~~ adjust head up void Adj_HU(){ SAdj[6]-=50;SAdj[7]+=25;SAdj[26]+=50;SAdj[27]-=25;SAdj[2]+=50;SAdj[3]-=25;SAdj[30]-=50;SAdj[31]+=25; Pos_SRV(); } //~~~~~~~~ adjust head down void Adj_HD(){ SAdj[6]+=50;SAdj[7]-=25;SAdj[26]-=50;SAdj[27]+=25;SAdj[2]-=50;SAdj[3]+=25;SAdj[30]+=50;SAdj[31]-=25; Pos_SRV(); } //~~~~~~~~ adjust body left void Adj_LF(){ SAdj[6]+=50;SAdj[7]-=25;SAdj[14]+=50;SAdj[15]-=25;SAdj[26]+=50;SAdj[27]-=25;SAdj[2]+=50;SAdj[3]-=25;SAdj[18]+=50;SAdj[19]-=25;SAdj[30]+=50;SAdj[31]-=25; Pos_SRV(); } //~~~~~~~~ adjust body right void Adj_RG(){ SAdj[6]-=50;SAdj[7]+=25;SAdj[14]-=50;SAdj[15]+=25;SAdj[26]-=50;SAdj[27]+=25;SAdj[2]-=50;SAdj[3]+=25;SAdj[18]-=50;SAdj[19]+=25;SAdj[30]-=50;SAdj[31]+=25; Pos_SRV(); } //~~~~~~~~ adjust twist left void Adj_TL(){ SAdj[5]-=50;SAdj[13]-=50;SAdj[25]-=50;SAdj[1]-=50;SAdj[17]-=50;SAdj[29]-=50; Pos_SRV(); } //~~~~~~~~ adjust twist right void Adj_TR(){ SAdj[5]+=50;SAdj[13]+=50;SAdj[25]+=50;SAdj[1]+=50;SAdj[17]+=50;SAdj[29]+=50; Pos_SRV(); } //~~~~~~~~ move forward void Move_FWD(){ SMov[29]=SAdj[29]+1490;SMov[30]=SAdj[30]+790;SMov[31]=SAdj[31]+1990;SMov[17]=SAdj[17]+1625;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1300;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1480;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1830;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1415;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1690;SMov[30]=SAdj[30]+790;SMov[31]=SAdj[31]+1990;SMov[17]=SAdj[17]+1550;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1225;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1555;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1680;SMov[14]=SAdj[14]+2090;SMov[15]=SAdj[15]+990;SMov[25]=SAdj[25]+1490;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1890;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1475;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1150;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1630;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1530;SMov[14]=SAdj[14]+2090;SMov[15]=SAdj[15]+990;SMov[25]=SAdj[25]+1565;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1815;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1400;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1300;SMov[2]=SAdj[2]+790;SMov[3]=SAdj[3]+1890;SMov[5]=SAdj[5]+1700;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1380;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1640;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1740;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1325;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1450;SMov[2]=SAdj[2]+790;SMov[3]=SAdj[3]+1890;SMov[5]=SAdj[5]+1780;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1455;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1590;SMov[26]=SAdj[26]+2090;SMov[27]=SAdj[27]+890;Send_Comm(); SMov[29]=SAdj[29]+1665;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1250;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1600;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1855;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1530;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1390;SMov[26]=SAdj[26]+2090;SMov[27]=SAdj[27]+890;Send_Comm(); SMov[29]=SAdj[29]+1590;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1400;SMov[18]=SAdj[18]+790;SMov[19]=SAdj[19]+1890;SMov[1]=SAdj[1]+1525;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1930;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1605;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1190;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1515;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1550;SMov[18]=SAdj[18]+790;SMov[19]=SAdj[19]+1890;SMov[1]=SAdj[1]+1450;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1780;SMov[6]=SAdj[6]+2090;SMov[7]=SAdj[7]+990;SMov[13]=SAdj[13]+1680;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1265;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1440;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1700;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1380;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1630;SMov[6]=SAdj[6]+2090;SMov[7]=SAdj[7]+990;SMov[13]=SAdj[13]+1755;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1340;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); } //~~~~~~~~ move backward void Move_BWD(){ SMov[29]=SAdj[29]+1440;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1700;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1380;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1630;SMov[6]=SAdj[6]+2090;SMov[7]=SAdj[7]+990;SMov[13]=SAdj[13]+1755;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1340;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1515;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1550;SMov[18]=SAdj[18]+790;SMov[19]=SAdj[19]+1890;SMov[1]=SAdj[1]+1450;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1780;SMov[6]=SAdj[6]+2090;SMov[7]=SAdj[7]+990;SMov[13]=SAdj[13]+1680;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1265;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1590;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1400;SMov[18]=SAdj[18]+790;SMov[19]=SAdj[19]+1890;SMov[1]=SAdj[1]+1525;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1930;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1605;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1190;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1665;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1250;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1600;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1855;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1530;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1390;SMov[26]=SAdj[26]+2090;SMov[27]=SAdj[27]+890;Send_Comm(); SMov[29]=SAdj[29]+1740;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1325;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1450;SMov[2]=SAdj[2]+790;SMov[3]=SAdj[3]+1890;SMov[5]=SAdj[5]+1780;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1455;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1590;SMov[26]=SAdj[26]+2090;SMov[27]=SAdj[27]+890;Send_Comm(); SMov[29]=SAdj[29]+1815;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1400;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1300;SMov[2]=SAdj[2]+790;SMov[3]=SAdj[3]+1890;SMov[5]=SAdj[5]+1700;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1380;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1640;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1890;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1475;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1150;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1630;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1530;SMov[14]=SAdj[14]+2090;SMov[15]=SAdj[15]+990;SMov[25]=SAdj[25]+1565;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1690;SMov[30]=SAdj[30]+790;SMov[31]=SAdj[31]+1990;SMov[17]=SAdj[17]+1550;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1225;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1555;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1680;SMov[14]=SAdj[14]+2090;SMov[15]=SAdj[15]+990;SMov[25]=SAdj[25]+1490;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1490;SMov[30]=SAdj[30]+790;SMov[31]=SAdj[31]+1990;SMov[17]=SAdj[17]+1625;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1300;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1480;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1830;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1415;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); } //~~~~~~~~ turn left void Move_LFT(){ SMov[29]=SAdj[29]+1490;SMov[30]=SAdj[30]+790;SMov[31]=SAdj[31]+1990;SMov[17]=SAdj[17]+1625;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1300;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1630;SMov[6]=SAdj[6]+2090;SMov[7]=SAdj[7]+990;SMov[13]=SAdj[13]+1755;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1340;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1690;SMov[30]=SAdj[30]+790;SMov[31]=SAdj[31]+1990;SMov[17]=SAdj[17]+1550;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1225;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1780;SMov[6]=SAdj[6]+2090;SMov[7]=SAdj[7]+990;SMov[13]=SAdj[13]+1680;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1265;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1890;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1475;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1150;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1930;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1605;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1190;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1815;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1400;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1300;SMov[2]=SAdj[2]+790;SMov[3]=SAdj[3]+1890;SMov[5]=SAdj[5]+1855;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1530;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1390;SMov[26]=SAdj[26]+2090;SMov[27]=SAdj[27]+890;Send_Comm(); SMov[29]=SAdj[29]+1740;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1325;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1450;SMov[2]=SAdj[2]+790;SMov[3]=SAdj[3]+1890;SMov[5]=SAdj[5]+1780;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1455;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1590;SMov[26]=SAdj[26]+2090;SMov[27]=SAdj[27]+890;Send_Comm(); SMov[29]=SAdj[29]+1665;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1250;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1600;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1700;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1380;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1640;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1590;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1400;SMov[18]=SAdj[18]+790;SMov[19]=SAdj[19]+1890;SMov[1]=SAdj[1]+1525;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1630;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1530;SMov[14]=SAdj[14]+2090;SMov[15]=SAdj[15]+990;SMov[25]=SAdj[25]+1565;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1515;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1550;SMov[18]=SAdj[18]+790;SMov[19]=SAdj[19]+1890;SMov[1]=SAdj[1]+1450;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1555;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1680;SMov[14]=SAdj[14]+2090;SMov[15]=SAdj[15]+990;SMov[25]=SAdj[25]+1490;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1440;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1700;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1380;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1480;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1830;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1415;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); } //~~~~~~~~ turn right void Move_RGT(){ SMov[29]=SAdj[29]+1440;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1700;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1380;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1480;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1830;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1415;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1515;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1550;SMov[18]=SAdj[18]+790;SMov[19]=SAdj[19]+1890;SMov[1]=SAdj[1]+1450;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1555;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1680;SMov[14]=SAdj[14]+2090;SMov[15]=SAdj[15]+990;SMov[25]=SAdj[25]+1490;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1590;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1400;SMov[18]=SAdj[18]+790;SMov[19]=SAdj[19]+1890;SMov[1]=SAdj[1]+1525;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1630;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1530;SMov[14]=SAdj[14]+2090;SMov[15]=SAdj[15]+990;SMov[25]=SAdj[25]+1565;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1665;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1250;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1600;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1700;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1380;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1640;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1740;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1325;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1450;SMov[2]=SAdj[2]+790;SMov[3]=SAdj[3]+1890;SMov[5]=SAdj[5]+1780;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1455;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1590;SMov[26]=SAdj[26]+2090;SMov[27]=SAdj[27]+890;Send_Comm(); SMov[29]=SAdj[29]+1815;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1400;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1300;SMov[2]=SAdj[2]+790;SMov[3]=SAdj[3]+1890;SMov[5]=SAdj[5]+1855;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1530;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1390;SMov[26]=SAdj[26]+2090;SMov[27]=SAdj[27]+890;Send_Comm(); SMov[29]=SAdj[29]+1890;SMov[30]=SAdj[30]+1440;SMov[31]=SAdj[31]+1490;SMov[17]=SAdj[17]+1475;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1150;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1930;SMov[6]=SAdj[6]+1440;SMov[7]=SAdj[7]+1440;SMov[13]=SAdj[13]+1605;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1190;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1690;SMov[30]=SAdj[30]+790;SMov[31]=SAdj[31]+1990;SMov[17]=SAdj[17]+1550;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1225;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1780;SMov[6]=SAdj[6]+2090;SMov[7]=SAdj[7]+990;SMov[13]=SAdj[13]+1680;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1265;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); SMov[29]=SAdj[29]+1490;SMov[30]=SAdj[30]+790;SMov[31]=SAdj[31]+1990;SMov[17]=SAdj[17]+1625;SMov[18]=SAdj[18]+1440;SMov[19]=SAdj[19]+1440;SMov[1]=SAdj[1]+1300;SMov[2]=SAdj[2]+1440;SMov[3]=SAdj[3]+1440;SMov[5]=SAdj[5]+1630;SMov[6]=SAdj[6]+2090;SMov[7]=SAdj[7]+990;SMov[13]=SAdj[13]+1755;SMov[14]=SAdj[14]+1440;SMov[15]=SAdj[15]+1440;SMov[25]=SAdj[25]+1340;SMov[26]=SAdj[26]+1440;SMov[27]=SAdj[27]+1390;Send_Comm(); } //================================================================================= Servo Move end ======================================================================= ",16285,True,4411.324394696646,median "/* ClipWindow.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8g2lib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1306_72X40_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); /* Uno: A4=SDA, A5=SCL, add ""u8g2.setBusClock(400000);"" into setup() for speedup if possible */ //U8G2_SSD1327_WS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_VISIONOX_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_RAYSTAR_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_RAYSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_KS0713_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_KS0713_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_OS12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7567_HEM6432_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_IST7920_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_IST7920_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_DEM240064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1617_JLX128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1617_JLX128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list void setup(void) { /* U8g2 Project: SSD1306 Test Board */ //pinMode(10, OUTPUT); //pinMode(9, OUTPUT); //digitalWrite(10, 0); //digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); /* U8g2 Project: LC7981 Test Board, connect RW to GND */ //pinMode(17, OUTPUT); //digitalWrite(17, 0); /* U8g2 Project: Pax Instruments Shield: Enable Backlight */ //pinMode(6, OUTPUT); //digitalWrite(6, 0); u8g2.begin(); } u8g2_uint_t x = 0; void loop(void) { if ( x == 0 ) x = 40; else x--; u8g2.setFont(u8g2_font_ncenB10_tr); u8g2.firstPage(); do { /* assign a clip window and draw some text into it */ u8g2.setClipWindow(35, 11, 74, 27); /* upper left and lower right position */ u8g2.drawStr(x,23,""U8g2 U8g2""); /* remove clip window, draw to complete screen */ u8g2.setMaxClipWindow(); u8g2.drawFrame(34, 10, 40, 18); } while ( u8g2.nextPage() ); delay(10); } ",16276,True,4981.058376724533,median "package com.ankamagames.dofus.logic.game.approach.frames { import by.blooddy.crypto.MD5; import com.ankamagames.berilia.Berilia; import com.ankamagames.berilia.managers.KernelEventsManager; import com.ankamagames.berilia.managers.UiModuleManager; import com.ankamagames.berilia.types.data.UiModule; import com.ankamagames.berilia.types.messages.AllModulesLoadedMessage; import com.ankamagames.berilia.types.shortcut.Shortcut; import com.ankamagames.dofus.BuildInfos; import com.ankamagames.dofus.Constants; import com.ankamagames.dofus.console.moduleLUA.ConsoleLUA; import com.ankamagames.dofus.console.moduleLogger.Console; import com.ankamagames.dofus.console.moduleLogger.ModuleDebugManager; import com.ankamagames.dofus.datacenter.servers.Server; import com.ankamagames.dofus.externalnotification.ExternalNotificationManager; import com.ankamagames.dofus.internalDatacenter.connection.BasicCharacterWrapper; import com.ankamagames.dofus.internalDatacenter.connection.CreationCharacterWrapper; import com.ankamagames.dofus.internalDatacenter.items.ItemWrapper; import com.ankamagames.dofus.kernel.Kernel; import com.ankamagames.dofus.kernel.net.ConnectionsHandler; import com.ankamagames.dofus.logic.common.frames.FeatureFrame; import com.ankamagames.dofus.logic.common.frames.LoadingModuleFrame; import com.ankamagames.dofus.logic.common.frames.MiscFrame; import com.ankamagames.dofus.logic.common.managers.FeatureManager; import com.ankamagames.dofus.logic.common.managers.PlayerManager; import com.ankamagames.dofus.logic.connection.frames.GameStartingFrame; import com.ankamagames.dofus.logic.connection.frames.ServerSelectionFrame; import com.ankamagames.dofus.logic.connection.managers.AuthentificationManager; import com.ankamagames.dofus.logic.game.approach.actions.CharacterCreationAction; import com.ankamagames.dofus.logic.game.approach.actions.CharacterDeletionAction; import com.ankamagames.dofus.logic.game.approach.actions.CharacterDeselectionAction; import com.ankamagames.dofus.logic.game.approach.actions.CharacterNameSuggestionRequestAction; import com.ankamagames.dofus.logic.game.approach.actions.CharacterRemodelSelectionAction; import com.ankamagames.dofus.logic.game.approach.actions.CharacterReplayRequestAction; import com.ankamagames.dofus.logic.game.approach.actions.CharacterSelectionAction; import com.ankamagames.dofus.logic.game.approach.actions.GiftAssignRequestAction; import com.ankamagames.dofus.logic.game.common.actions.CharacterAutoConnectAction; import com.ankamagames.dofus.logic.game.common.actions.chat.PopupWarningCloseRequestAction; import com.ankamagames.dofus.logic.game.common.frames.AdministrablePopupFrame; import com.ankamagames.dofus.logic.game.common.frames.AlignmentFrame; import com.ankamagames.dofus.logic.game.common.frames.AllianceFrame; import com.ankamagames.dofus.logic.game.common.frames.AveragePricesFrame; import com.ankamagames.dofus.logic.game.common.frames.CameraControlFrame; import com.ankamagames.dofus.logic.game.common.frames.ChatFrame; import com.ankamagames.dofus.logic.game.common.frames.CommonUiFrame; import com.ankamagames.dofus.logic.game.common.frames.ContextChangeFrame; import com.ankamagames.dofus.logic.game.common.frames.EmoticonFrame; import com.ankamagames.dofus.logic.game.common.frames.ExternalGameFrame; import com.ankamagames.dofus.logic.game.common.frames.ForgettableSpellsUiFrame; import com.ankamagames.dofus.logic.game.common.frames.HouseFrame; import com.ankamagames.dofus.logic.game.common.frames.IdolsFrame; import com.ankamagames.dofus.logic.game.common.frames.InventoryManagementFrame; import com.ankamagames.dofus.logic.game.common.frames.JobsFrame; import com.ankamagames.dofus.logic.game.common.frames.LivingObjectFrame; import com.ankamagames.dofus.logic.game.common.frames.MountFrame; import com.ankamagames.dofus.logic.game.common.frames.PartyManagementFrame; import com.ankamagames.dofus.logic.game.common.frames.PlayedCharacterUpdatesFrame; import com.ankamagames.dofus.logic.game.common.frames.ProgressionFrame; import com.ankamagames.dofus.logic.game.common.frames.ProtectPishingFrame; import com.ankamagames.dofus.logic.game.common.frames.QuestFrame; import com.ankamagames.dofus.logic.game.common.frames.ScreenCaptureFrame; import com.ankamagames.dofus.logic.game.common.frames.ServerTransferFrame; import com.ankamagames.dofus.logic.game.common.frames.SocialFrame; import com.ankamagames.dofus.logic.game.common.frames.SpellInventoryManagementFrame; import com.ankamagames.dofus.logic.game.common.frames.StackManagementFrame; import com.ankamagames.dofus.logic.game.common.frames.SynchronisationFrame; import com.ankamagames.dofus.logic.game.common.frames.TinselFrame; import com.ankamagames.dofus.logic.game.common.frames.WorldFrame; import com.ankamagames.dofus.logic.game.common.managers.DebtManager; import com.ankamagames.dofus.logic.game.common.managers.InactivityManager; import com.ankamagames.dofus.logic.game.common.managers.PlayedCharacterManager; import com.ankamagames.dofus.logic.game.common.managers.TimeManager; import com.ankamagames.dofus.logic.game.roleplay.frames.RoleplayIntroductionFrame; import com.ankamagames.dofus.logic.game.spin2.chat.ChatServiceManager; import com.ankamagames.dofus.logic.shield.SecureModeManager; import com.ankamagames.dofus.misc.interClient.InterClientManager; import com.ankamagames.dofus.misc.lists.HookList; import com.ankamagames.dofus.misc.stats.StatisticsManager; import com.ankamagames.dofus.misc.utils.errormanager.DofusErrorHandler; import com.ankamagames.dofus.network.ProtocolConstantsEnum; import com.ankamagames.dofus.network.enums.BuildTypeEnum; import com.ankamagames.dofus.network.enums.CharacterDeletionErrorEnum; import com.ankamagames.dofus.network.enums.CharacterRemodelingEnum; import com.ankamagames.dofus.network.enums.GameServerTypeEnum; import com.ankamagames.dofus.network.messages.authorized.ConsoleCommandsListMessage; import com.ankamagames.dofus.network.messages.game.approach.AccountCapabilitiesMessage; import com.ankamagames.dofus.network.messages.game.approach.AlreadyConnectedMessage; import com.ankamagames.dofus.network.messages.game.approach.AuthenticationTicketAcceptedMessage; import com.ankamagames.dofus.network.messages.game.approach.AuthenticationTicketMessage; import com.ankamagames.dofus.network.messages.game.approach.AuthenticationTicketRefusedMessage; import com.ankamagames.dofus.network.messages.game.approach.HelloGameMessage; import com.ankamagames.dofus.network.messages.game.basic.BasicTimeMessage; import com.ankamagames.dofus.network.messages.game.character.choice.BasicCharactersListMessage; import com.ankamagames.dofus.network.messages.game.character.choice.CharacterFirstSelectionMessage; import com.ankamagames.dofus.network.messages.game.character.choice.CharacterReplayWithRemodelRequestMessage; import com.ankamagames.dofus.network.messages.game.character.choice.CharacterSelectedErrorMessage; import com.ankamagames.dofus.network.messages.game.character.choice.CharacterSelectedForceMessage; import com.ankamagames.dofus.network.messages.game.character.choice.CharacterSelectedForceReadyMessage; import com.ankamagames.dofus.network.messages.game.character.choice.CharacterSelectedSuccessMessage; import com.ankamagames.dofus.network.messages.game.character.choice.CharacterSelectionMessage; import com.ankamagames.dofus.network.messages.game.character.choice.CharacterSelectionWithRemodelMessage; import com.ankamagames.dofus.network.messages.game.character.choice.CharactersListErrorMessage; import com.ankamagames.dofus.network.messages.game.character.choice.CharactersListMessage; import com.ankamagames.dofus.network.messages.game.character.choice.CharactersListRequestMessage; import com.ankamagames.dofus.network.messages.game.character.choice.CharactersListWithRemodelingMessage; import com.ankamagames.dofus.network.messages.game.character.creation.CharacterCanBeCreatedRequestMessage; import com.ankamagames.dofus.network.messages.game.character.creation.CharacterCanBeCreatedResultMessage; import com.ankamagames.dofus.network.messages.game.character.creation.CharacterCreationRequestMessage; import com.ankamagames.dofus.network.messages.game.character.creation.CharacterCreationResultMessage; import com.ankamagames.dofus.network.messages.game.character.creation.CharacterNameSuggestionFailureMessage; import com.ankamagames.dofus.network.messages.game.character.creation.CharacterNameSuggestionRequestMessage; import com.ankamagames.dofus.network.messages.game.character.creation.CharacterNameSuggestionSuccessMessage; import com.ankamagames.dofus.network.messages.game.character.deletion.CharacterDeletionErrorMessage; import com.ankamagames.dofus.network.messages.game.character.deletion.CharacterDeletionRequestMessage; import com.ankamagames.dofus.network.messages.game.character.replay.CharacterReplayRequestMessage; import com.ankamagames.dofus.network.messages.game.context.GameContextCreateRequestMessage; import com.ankamagames.dofus.network.messages.game.context.roleplay.fight.arena.GameRolePlayArenaSwitchToFightServerMessage; import com.ankamagames.dofus.network.messages.game.moderation.PopupWarningCloseRequestMessage; import com.ankamagames.dofus.network.messages.game.moderation.PopupWarningClosedMessage; import com.ankamagames.dofus.network.messages.game.startup.StartupActionFinishedMessage; import com.ankamagames.dofus.network.messages.game.startup.StartupActionsExecuteMessage; import com.ankamagames.dofus.network.messages.game.startup.StartupActionsListMessage; import com.ankamagames.dofus.network.messages.game.startup.StartupActionsObjetAttributionMessage; import com.ankamagames.dofus.network.messages.security.ClientKeyMessage; import com.ankamagames.dofus.network.types.game.character.choice.CharacterBaseInformations; import com.ankamagames.dofus.network.types.game.character.choice.CharacterHardcoreOrEpicInformations; import com.ankamagames.dofus.network.types.game.character.choice.CharacterToRemodelInformations; import com.ankamagames.dofus.network.types.game.character.choice.RemodelingInformation; import com.ankamagames.dofus.network.types.game.data.items.ObjectItemInformationWithQuantity; import com.ankamagames.dofus.network.types.game.startup.StartupActionAddObject; import com.ankamagames.dofus.scripts.api.CameraApi; import com.ankamagames.dofus.scripts.api.EntityApi; import com.ankamagames.dofus.scripts.api.ScriptSequenceApi; import com.ankamagames.dofus.types.data.ServerCommand; import com.ankamagames.dofus.uiApi.DataApi; import com.ankamagames.dofus.uiApi.SoundApi; import com.ankamagames.jerakine.data.I18n; import com.ankamagames.jerakine.data.XmlConfig; import com.ankamagames.jerakine.logger.Log; import com.ankamagames.jerakine.logger.LogLogger; import com.ankamagames.jerakine.logger.Logger; import com.ankamagames.jerakine.lua.LuaPlayer; import com.ankamagames.jerakine.managers.LangManager; import com.ankamagames.jerakine.managers.OptionManager; import com.ankamagames.jerakine.managers.StoreDataManager; import com.ankamagames.jerakine.messages.ConnectionResumedMessage; import com.ankamagames.jerakine.messages.Frame; import com.ankamagames.jerakine.messages.Message; import com.ankamagames.jerakine.network.messages.ServerConnectionFailedMessage; import com.ankamagames.jerakine.script.ScriptsManager; import com.ankamagames.jerakine.types.DataStoreType; import com.ankamagames.jerakine.types.enums.DataStoreEnum; import com.ankamagames.jerakine.types.enums.Priority; import com.ankamagames.jerakine.utils.benchmark.monitoring.FpsManager; import com.ankamagames.jerakine.utils.system.AirScanner; import flash.display.Loader; import flash.system.ApplicationDomain; import flash.system.LoaderContext; import flash.utils.getQualifiedClassName; import flash.utils.setTimeout; import scopart.raven.RavenClient; public class GameServerApproachFrame implements Frame { protected static const _log:Logger = Log.getLogger(getQualifiedClassName(GameServerApproachFrame)); private static var _changeLogLoader:Loader = new Loader(); public static var authenticationTicketAccepted:Boolean = false; private const LOADING_TIMEOUT:uint = 60000.0; private var _charactersList:Vector.; private var _charactersToRemodelList:Array; private var _kernel:KernelEventsManager; private var _gmaf:LoadingModuleFrame; private var _loadingStart:Number; private var _waitingMessages:Vector.; private var _cssmsg:CharacterSelectedSuccessMessage; private var _requestedCharacterId:Number; private var _requestedToRemodelCharacterId:Number; private var _waitingForListRefreshAfterDeletion:Boolean; private var _lc:LoaderContext; private var commonMod:Object; private var _giftList:Array; private var _charaListMinusDeadPeople:Array; private var _reconnectMsgSend:Boolean = false; private var _openCharsList:Boolean = true; public function GameServerApproachFrame() { this._charactersList = new Vector.(); this._charactersToRemodelList = []; this._kernel = KernelEventsManager.getInstance(); this._lc = new LoaderContext(false,ApplicationDomain.currentDomain); this.commonMod = UiModuleManager.getInstance().getModule(""Ankama_Common"").mainClass; this._giftList = []; this._charaListMinusDeadPeople = []; super(); } public function get priority() : int { return Priority.NORMAL; } public function get giftList() : Array { return this._giftList; } public function get charaListMinusDeadPeople() : Array { return this._charaListMinusDeadPeople; } public function get requestedCharaId() : Number { return this._requestedCharacterId; } public function set requestedCharaId(id:Number) : void { this._requestedCharacterId = id; } public function isCharacterWaitingForChange(id:Number) : Boolean { if(this._charactersToRemodelList[id]) { return true; } return false; } public function pushed() : Boolean { SecureModeManager.getInstance().checkMigrate(); AirScanner.allowByteCodeExecution(this._lc,true); Kernel.getWorker().addFrame(new MiscFrame()); Kernel.getWorker().addFrame(new FeatureFrame()); return true; } public function process(msg:Message) : Boolean { var perso:BasicCharacterWrapper = null; var characterId:Number = NaN; var isReplay:Boolean = false; var atmsg:AuthenticationTicketMessage = null; var atrmsg:AuthenticationTicketRefusedMessage = null; var scfMsg:ServerConnectionFailedMessage = null; var acmsg:AlreadyConnectedMessage = null; var clmsg:CharactersListMessage = null; var unusableCharacters:Vector. = null; var o:BasicCharacterWrapper = null; var unusable:Boolean = false; var server:Server = null; var bonusXp:int = 0; var mod:UiModule = null; var dst:DataStoreType = null; var isCharacterCreationDisplayForced:Boolean = false; var bclmsg:BasicCharactersListMessage = null; var b:BasicCharacterWrapper = null; var ccbcmsg:CharacterCanBeCreatedResultMessage = null; var accmsg:AccountCapabilitiesMessage = null; var cca:CharacterCreationAction = null; var ccmsg:CharacterCreationRequestMessage = null; var colors:Vector. = null; var ccrmsg:CharacterCreationResultMessage = null; var cda:CharacterDeletionAction = null; var cdrmsg:CharacterDeletionRequestMessage = null; var cdemsg:CharacterDeletionErrorMessage = null; var reason:String = null; var cnsra:CharacterNameSuggestionRequestAction = null; var cnsrmsg:CharacterNameSuggestionRequestMessage = null; var cnssmsg:CharacterNameSuggestionSuccessMessage = null; var cnsfmsg:CharacterNameSuggestionFailureMessage = null; var crsa:CharacterRemodelSelectionAction = null; var remodel:RemodelingInformation = null; var tempColorsArray:Vector. = null; var characterToConnect:BasicCharacterWrapper = null; var currentServer:Server = null; var bTutorial:Boolean = false; var cssmsg:CharacterSelectedSuccessMessage = null; var isRelease:* = false; var gccrmsg:GameContextCreateRequestMessage = null; var soundApi:SoundApi = null; var devMode:* = false; var now:Number = NaN; var delta:Number = NaN; var csemsg:CharacterSelectedErrorMessage = null; var btmsg:BasicTimeMessage = null; var date:Date = null; var salm:StartupActionsListMessage = null; var cclMsg:ConsoleCommandsListMessage = null; var stf:ServerTransferFrame = null; var pwcrmsg:PopupWarningCloseRequestMessage = null; var ccbcrm:CharacterCanBeCreatedRequestMessage = null; var clwrmsg:CharactersListWithRemodelingMessage = null; var ctri:CharacterToRemodelInformations = null; var chi:CharacterHardcoreOrEpicInformations = null; var featureManager:FeatureManager = null; var bonusXpFeatureActivated:Boolean = false; var cbi:CharacterBaseInformations = null; var cbi2:CharacterBaseInformations = null; var charToConnect:BasicCharacterWrapper = null; var saem:StartupActionsExecuteMessage = null; var ccbcrmsg:CharacterCanBeCreatedRequestMessage = null; var bChi:CharacterHardcoreOrEpicInformations = null; var bCbi:CharacterBaseInformations = null; var c:* = undefined; var colorIndex:* = undefined; var colorInteger:* = 0; var person2:Object = null; var crwrrmsg:CharacterReplayWithRemodelRequestMessage = null; var cswrmsg:CharacterSelectionWithRemodelMessage = null; var charToRemodel:Object = null; var indexedColors:Vector. = null; var char:CreationCharacterWrapper = null; var modificationModules:Array = null; var mandatoryModules:Array = null; var firstSelection:Boolean = false; var cfsmsg:CharacterFirstSelectionMessage = null; var crrmsg:CharacterReplayRequestMessage = null; var csmsg:CharacterSelectionMessage = null; var j:int = 0; var bchar:BasicCharacterWrapper = null; var flashKeyMsg:ClientKeyMessage = null; var fpsManagerState:uint = 0; var i:uint = 0; var luaPlayer:LuaPlayer = null; var tag:Object = null; var gift:StartupActionAddObject = null; var _items:Array = null; var item:ObjectItemInformationWithQuantity = null; var oj:Object = null; var iw:ItemWrapper = null; var gar:GiftAssignRequestAction = null; var sao:StartupActionsObjetAttributionMessage = null; var safm:StartupActionFinishedMessage = null; var indexToDelete:int = 0; var giftAction:Object = null; var cmdIndex:uint = 0; switch(true) { case msg is HelloGameMessage: ConnectionsHandler.confirmGameServerConnection(); authenticationTicketAccepted = false; atmsg = new AuthenticationTicketMessage(); atmsg.initAuthenticationTicketMessage(LangManager.getInstance().getEntry(""config.lang.current""),AuthentificationManager.getInstance().gameServerTicket); ConnectionsHandler.getConnection().send(atmsg); InactivityManager.getInstance().start(); this._kernel.processCallback(HookList.AuthenticationTicket); return true; case msg is AuthenticationTicketAcceptedMessage: setTimeout(this.requestCharactersList,500); authenticationTicketAccepted = true; this._kernel.processCallback(HookList.AuthenticationTicketAccepted); return true; case msg is AuthenticationTicketRefusedMessage: atrmsg = msg as AuthenticationTicketRefusedMessage; authenticationTicketAccepted = false; this._kernel.processCallback(HookList.AuthenticationTicketRefused); return true; case msg is ServerConnectionFailedMessage: scfMsg = ServerConnectionFailedMessage(msg); authenticationTicketAccepted = false; if(scfMsg.failedConnection == ConnectionsHandler.getConnection().getSubConnection(scfMsg)) { PlayerManager.getInstance().destroy(); this.commonMod.openPopup(I18n.getUiText(""ui.common.error""),I18n.getUiText(""ui.connexion.gameConnexionFailed""),[I18n.getUiText(""ui.common.ok"")],[this.onEscapePopup],this.onEscapePopup,this.onEscapePopup); KernelEventsManager.getInstance().processCallback(HookList.SelectedServerFailed); } return true; case msg is AlreadyConnectedMessage: acmsg = AlreadyConnectedMessage(msg); PlayerManager.getInstance().wasAlreadyConnected = true; KernelEventsManager.getInstance().processCallback(HookList.AlreadyConnected); return true; case msg is CharactersListMessage: clmsg = msg as CharactersListMessage; if(this._waitingForListRefreshAfterDeletion) { ccbcrm = new CharacterCanBeCreatedRequestMessage(); ccbcrm.initCharacterCanBeCreatedRequestMessage(); ConnectionsHandler.getConnection().send(ccbcrm); this._waitingForListRefreshAfterDeletion = false; } unusableCharacters = new Vector.(); if(msg is CharactersListWithRemodelingMessage) { clwrmsg = msg as CharactersListWithRemodelingMessage; for each(ctri in clwrmsg.charactersToRemodel) { this._charactersToRemodelList[ctri.id] = ctri; } } this._charactersList = new Vector.(); unusable = false; server = PlayerManager.getInstance().server; bonusXp = 1; if(FeatureManager.getInstance().isFeatureWithKeywordEnabled(""server.heroic"") || server.gameTypeId == GameServerTypeEnum.SERVER_TYPE_EPIC) { for each(chi in clmsg.characters) { if(unusableCharacters.indexOf(chi.id) != -1) { unusable = true; } if(chi.deathMaxLevel > chi.level) { bonusXp = 6; } else { bonusXp = 3; } o = BasicCharacterWrapper.create(chi.id,chi.name,chi.level,chi.entityLook,chi.breed,chi.sex,chi.deathState,chi.deathCount,chi.deathMaxLevel,bonusXp,unusable); this._charactersList.push(o); } } else { featureManager = FeatureManager.getInstance(); bonusXpFeatureActivated = !featureManager || featureManager.isFeatureWithKeywordEnabled(""character.xp.bonusForYoungerCharacters""); for each(cbi in clmsg.characters) { bonusXp = 1; if(unusableCharacters.indexOf(cbi.id) != -1) { unusable = true; } if(bonusXpFeatureActivated) { for each(cbi2 in clmsg.characters) { if(cbi2.id != cbi.id && cbi2.level > cbi.level && bonusXp < 4) { bonusXp++; } } } o = BasicCharacterWrapper.create(cbi.id,cbi.name,cbi.level,cbi.entityLook,cbi.breed,cbi.sex,0,0,0,bonusXp,unusable); this._charactersList.push(o); } } PlayerManager.getInstance().charactersList = this._charactersList; mod = UiModuleManager.getInstance().getModule(""Ankama_Connection""); dst = new DataStoreType(""AccountModule_"" + mod.id,true,DataStoreEnum.LOCATION_LOCAL,DataStoreEnum.BIND_ACCOUNT); isCharacterCreationDisplayForced = StoreDataManager.getInstance().getData(dst,""forceCharacterCreationDisplay""); if(this._charactersList.length && !isCharacterCreationDisplayForced) { this._openCharsList = true; charToConnect = this.getCharacterToConnect(); if(clmsg.hasStartupActions && !charToConnect) { saem = new StartupActionsExecuteMessage(); saem.initStartupActionsExecuteMessage(); ConnectionsHandler.getConnection().send(saem); this._openCharsList = false; } else if(charToConnect) { this.launchAutoConnect(charToConnect,server); } if(this._openCharsList) { if(!Berilia.getInstance().getUi(""characterSelection"")) { this._kernel.processCallback(HookList.CharacterSelectionStart,this._charactersList); } else { this._kernel.processCallback(HookList.CharactersListUpdated,this._charactersList); } } } else { this._kernel.processCallback(HookList.CharacterCreationStart,[[""create""],true]); this._kernel.processCallback(HookList.CharactersListUpdated,this._charactersList); } return true; case msg is BasicCharactersListMessage: bclmsg = msg as BasicCharactersListMessage; if(this._waitingForListRefreshAfterDeletion) { ccbcrmsg = new CharacterCanBeCreatedRequestMessage(); ccbcrmsg.initCharacterCanBeCreatedRequestMessage(); ConnectionsHandler.getConnection().send(ccbcrmsg); this._waitingForListRefreshAfterDeletion = false; } this._charactersList = new Vector.(); if(FeatureManager.getInstance().isFeatureWithKeywordEnabled(""server.heroic"") || PlayerManager.getInstance().server.gameTypeId == GameServerTypeEnum.SERVER_TYPE_EPIC) { for each(bChi in bclmsg.characters) { b = BasicCharacterWrapper.create(bChi.id,bChi.name,bChi.level,bChi.entityLook,bChi.breed,bChi.sex,bChi.deathState,bChi.deathCount,bChi.deathMaxLevel,1,false); this._charactersList.push(b); } } else { for each(bCbi in bclmsg.characters) { b = BasicCharacterWrapper.create(bCbi.id,bCbi.name,bCbi.level,bCbi.entityLook,bCbi.breed,bCbi.sex,0,0,0,1,false); this._charactersList.push(b); } } PlayerManager.getInstance().charactersList = this._charactersList; return true; case msg is CharactersListErrorMessage: this.commonMod.openPopup(I18n.getUiText(""ui.common.error""),I18n.getUiText(""ui.connexion.charactersListError""),[I18n.getUiText(""ui.common.ok"")]); return false; case msg is CharacterCanBeCreatedResultMessage: ccbcmsg = msg as CharacterCanBeCreatedResultMessage; PlayerManager.getInstance().canCreateNewCharacter = ccbcmsg.yesYouCan; KernelEventsManager.getInstance().processCallback(HookList.CharacterCanBeCreated); return true; case msg is AccountCapabilitiesMessage: accmsg = msg as AccountCapabilitiesMessage; this._kernel.processCallback(HookList.TutorielAvailable,accmsg.tutorialAvailable); this._kernel.processCallback(HookList.BreedsAvailable,accmsg.breedsAvailable,accmsg.breedsVisible); PlayerManager.getInstance().adminStatus = accmsg.status; PlayerManager.getInstance().canCreateNewCharacter = accmsg.canCreateNewCharacter; KernelEventsManager.getInstance().processCallback(HookList.CharacterCreationStart,[[""create""]]); return true; case msg is CharacterCreationAction: cca = msg as CharacterCreationAction; ccmsg = new CharacterCreationRequestMessage(); colors = new Vector.(); for each(c in cca.colors) { colors.push(c); } while(colors.length < ProtocolConstantsEnum.MAX_PLAYER_COLOR) { colors.push(-1); } ccmsg.initCharacterCreationRequestMessage(cca.name,cca.breed,cca.sex,colors,cca.head); ConnectionsHandler.getConnection().send(ccmsg); return true; case msg is CharacterCreationResultMessage: ccrmsg = msg as CharacterCreationResultMessage; this._kernel.processCallback(HookList.CharacterCreationResult,ccrmsg.result); return true; case msg is CharacterDeletionAction: cda = msg as CharacterDeletionAction; this._waitingForListRefreshAfterDeletion = true; cdrmsg = new CharacterDeletionRequestMessage(); cdrmsg.initCharacterDeletionRequestMessage(cda.id,MD5.hash(cda.id + ""~"" + cda.answer)); ConnectionsHandler.getConnection().send(cdrmsg); return true; case msg is CharacterDeletionErrorMessage: cdemsg = msg as CharacterDeletionErrorMessage; this._waitingForListRefreshAfterDeletion = false; reason = """"; if(cdemsg.reason == CharacterDeletionErrorEnum.DEL_ERR_TOO_MANY_CHAR_DELETION) { reason = ""TooManyDeletion""; } else if(cdemsg.reason == CharacterDeletionErrorEnum.DEL_ERR_BAD_SECRET_ANSWER) { reason = ""WrongAnswer""; } else if(cdemsg.reason == CharacterDeletionErrorEnum.DEL_ERR_RESTRICED_ZONE) { reason = ""UnsecureMode""; } this._kernel.processCallback(HookList.CharacterDeletionError,reason); this._requestedCharacterId = 0; return true; case msg is CharacterNameSuggestionRequestAction: cnsra = msg as CharacterNameSuggestionRequestAction; cnsrmsg = new CharacterNameSuggestionRequestMessage(); cnsrmsg.initCharacterNameSuggestionRequestMessage(); ConnectionsHandler.getConnection().send(cnsrmsg); return true; case msg is CharacterNameSuggestionSuccessMessage: cnssmsg = msg as CharacterNameSuggestionSuccessMessage; this._kernel.processCallback(HookList.CharacterNameSuggestioned,cnssmsg.suggestion); return true; case msg is CharacterNameSuggestionFailureMessage: cnsfmsg = msg as CharacterNameSuggestionFailureMessage; _log.error(""Generation de nom impossible !""); return true; case msg is CharacterSelectedForceMessage: if(!this._reconnectMsgSend) { Kernel.beingInReconection = true; characterId = CharacterSelectedForceMessage(msg).id; this._reconnectMsgSend = true; ConnectionsHandler.getConnection().send(new CharacterSelectedForceReadyMessage()); } return true; case msg is CharacterRemodelSelectionAction: crsa = msg as CharacterRemodelSelectionAction; remodel = new RemodelingInformation(); remodel.sex = crsa.sex; remodel.breed = crsa.breed; remodel.cosmeticId = crsa.cosmeticId; remodel.name = crsa.name; tempColorsArray = new Vector.(); for(colorIndex in crsa.colors) { colorInteger = int(crsa.colors[colorIndex]); if(colorInteger >= 0) { colorInteger &= 16777215; tempColorsArray.push(colorInteger | int(colorIndex) + 1 << 24); } } remodel.colors = tempColorsArray; if(FeatureManager.getInstance().isFeatureWithKeywordEnabled(""server.heroic"") || PlayerManager.getInstance().server.gameTypeId == GameServerTypeEnum.SERVER_TYPE_EPIC) { for each(person2 in this._charactersList) { if(person2.id == this._requestedToRemodelCharacterId) { if(person2.deathState == 1) { isReplay = true; } else if(person2.deathState == 0) { isReplay = false; } else { this.commonMod.openPopup(I18n.getUiText(""ui.common.error""),I18n.getUiText(""ui.common.cantSelectThisCharacterLimb""),[I18n.getUiText(""ui.common.ok"")]); } } } } else { isReplay = false; } if(isReplay) { crwrrmsg = new CharacterReplayWithRemodelRequestMessage(); crwrrmsg.initCharacterReplayWithRemodelRequestMessage(this._requestedToRemodelCharacterId,remodel); ConnectionsHandler.getConnection().send(crwrrmsg); } else { cswrmsg = new CharacterSelectionWithRemodelMessage(); cswrmsg.initCharacterSelectionWithRemodelMessage(this._requestedToRemodelCharacterId,remodel); ConnectionsHandler.getConnection().send(cswrmsg); } return true; case msg is CharacterDeselectionAction: this._requestedCharacterId = 0; return true; case msg is CharacterAutoConnectAction: characterToConnect = this.getCharacterToConnect(); currentServer = PlayerManager.getInstance().server; if(characterToConnect && currentServer) { this.launchAutoConnect(characterToConnect,currentServer); } break; case msg is CharacterSelectionAction: case msg is CharacterReplayRequestAction: if(this._requestedCharacterId) { return false; } bTutorial = false; if(msg is CharacterSelectionAction) { characterId = (msg as CharacterSelectionAction).characterId; bTutorial = (msg as CharacterSelectionAction).btutoriel; isReplay = false; } else if(msg is CharacterReplayRequestAction) { characterId = (msg as CharacterReplayRequestAction).characterId; bTutorial = false; isReplay = true; } this._requestedCharacterId = characterId; if(this._charactersToRemodelList[characterId]) { this._requestedToRemodelCharacterId = characterId; charToRemodel = this._charactersToRemodelList[characterId]; indexedColors = this.getCharacterColorsInformations(charToRemodel); char = CreationCharacterWrapper.create(charToRemodel.name,charToRemodel.sex,charToRemodel.breed,charToRemodel.cosmeticId,indexedColors); for each(perso in this._charactersList) { if(perso.id == characterId) { char.entityLook = perso.entityLook; } } modificationModules = []; if((charToRemodel.possibleChangeMask & CharacterRemodelingEnum.CHARACTER_REMODELING_BREED) > 0) { modificationModules.push(""rebreed""); } if((charToRemodel.possibleChangeMask & CharacterRemodelingEnum.CHARACTER_REMODELING_COLORS) > 0) { modificationModules.push(""recolor""); } if((charToRemodel.possibleChangeMask & CharacterRemodelingEnum.CHARACTER_REMODELING_COSMETIC) > 0) { modificationModules.push(""relook""); } if((charToRemodel.possibleChangeMask & CharacterRemodelingEnum.CHARACTER_REMODELING_NAME) > 0) { modificationModules.push(""rename""); } if((charToRemodel.possibleChangeMask & CharacterRemodelingEnum.CHARACTER_REMODELING_GENDER) > 0) { modificationModules.push(""regender""); } mandatoryModules = []; if((charToRemodel.mandatoryChangeMask & CharacterRemodelingEnum.CHARACTER_REMODELING_BREED) > 0) { mandatoryModules.push(""rebreed""); } if((charToRemodel.mandatoryChangeMask & CharacterRemodelingEnum.CHARACTER_REMODELING_COLORS) > 0) { mandatoryModules.push(""recolor""); } if((charToRemodel.mandatoryChangeMask & CharacterRemodelingEnum.CHARACTER_REMODELING_COSMETIC) > 0) { mandatoryModules.push(""relook""); } if((charToRemodel.mandatoryChangeMask & CharacterRemodelingEnum.CHARACTER_REMODELING_NAME) > 0) { mandatoryModules.push(""rename""); } if((charToRemodel.mandatoryChangeMask & CharacterRemodelingEnum.CHARACTER_REMODELING_GENDER) > 0) { mandatoryModules.push(""regender""); } if((charToRemodel.mandatoryChangeMask & CharacterRemodelingEnum.CHARACTER_OPT_REMODELING_NAME) > 0) { modificationModules.push(""rename""); } this._kernel.processCallback(HookList.CharacterCreationStart,[modificationModules,mandatoryModules,char]); } else { this._requestedToRemodelCharacterId = 0; firstSelection = bTutorial; if(bTutorial) { cfsmsg = new CharacterFirstSelectionMessage(); cfsmsg.initCharacterFirstSelectionMessage(characterId,true); ConnectionsHandler.getConnection().send(cfsmsg); } else if(isReplay) { crrmsg = new CharacterReplayRequestMessage(); crrmsg.initCharacterReplayRequestMessage(characterId); ConnectionsHandler.getConnection().send(crrmsg); } else { csmsg = new CharacterSelectionMessage(); csmsg.initCharacterSelectionMessage(characterId); ConnectionsHandler.getConnection().send(csmsg); } } return true; break; case msg is CharacterSelectedSuccessMessage: cssmsg = msg as CharacterSelectedSuccessMessage; this._loadingStart = new Date().time; ConnectionsHandler.pause(); if(Kernel.getWorker().getFrame(ServerSelectionFrame)) { Kernel.getWorker().removeFrame(Kernel.getWorker().getFrame(ServerSelectionFrame)); } if(this._gmaf == null) { this._gmaf = new LoadingModuleFrame(); Kernel.getWorker().addFrame(this._gmaf); } PlayedCharacterManager.getInstance().infos = cssmsg.infos; DataStoreType.CHARACTER_ID = cssmsg.infos.id.toString(); Kernel.getWorker().pause(); this._cssmsg = cssmsg; UiModuleManager.getInstance().reset(); if(PlayerManager.getInstance().hasRights) { UiModuleManager.getInstance().init(Constants.PRE_GAME_MODULE,false); } else { UiModuleManager.getInstance().init(Constants.PRE_GAME_MODULE.concat(Constants.ADMIN_MODULE),false); } Dofus.getInstance().renameApp(cssmsg.infos.name + "" - Dofus "" + BuildInfos.VERSION.toStringForAppName()); ExternalNotificationManager.getInstance().init(); if(cssmsg.isCollectingStats) { StatisticsManager.getInstance().startStats(""shortcuts""); } else { StatisticsManager.getInstance().quit(); } if(cssmsg.infos.id == this._requestedToRemodelCharacterId) { for(j = 0; j < this._charactersList.length; j++) { bchar = this._charactersList[j]; if(bchar.id == cssmsg.infos.id) { this._charactersList[j] = BasicCharacterWrapper.create(bchar.id,cssmsg.infos.name,cssmsg.infos.level,cssmsg.infos.entityLook,cssmsg.infos.breed,cssmsg.infos.sex,0,0,bchar.bonusXp); break; } } } DebtManager.clean(); return true; case msg is AllModulesLoadedMessage: _log.warn(""GameServerApproachFrame AllModulesLoaded""); this._gmaf = null; isRelease = BuildInfos.BUILD_TYPE == BuildTypeEnum.RELEASE; LogLogger.activeLog(!isRelease || isRelease && DofusErrorHandler.debugManuallyActivated); Kernel.getWorker().addFrame(new WorldFrame()); Kernel.getWorker().addFrame(new AlignmentFrame()); Kernel.getWorker().addFrame(new SynchronisationFrame()); Kernel.getWorker().addFrame(new LivingObjectFrame()); Kernel.getWorker().addFrame(new AllianceFrame()); Kernel.getWorker().addFrame(new PlayedCharacterUpdatesFrame()); Kernel.getWorker().addFrame(new SocialFrame()); Kernel.getWorker().addFrame(new SpellInventoryManagementFrame()); Kernel.getWorker().addFrame(new InventoryManagementFrame()); Kernel.getWorker().addFrame(new ContextChangeFrame()); Kernel.getWorker().addFrame(new CommonUiFrame()); Kernel.getWorker().addFrame(new ProgressionFrame()); Kernel.getWorker().addFrame(new ChatFrame()); Kernel.getWorker().addFrame(new JobsFrame()); Kernel.getWorker().addFrame(new MountFrame()); Kernel.getWorker().addFrame(new EmoticonFrame()); Kernel.getWorker().addFrame(new QuestFrame()); Kernel.getWorker().addFrame(new TinselFrame()); Kernel.getWorker().addFrame(new PartyManagementFrame()); Kernel.getWorker().addFrame(new ProtectPishingFrame()); Kernel.getWorker().addFrame(new StackManagementFrame()); Kernel.getWorker().addFrame(new ExternalGameFrame()); Kernel.getWorker().addFrame(new AveragePricesFrame()); Kernel.getWorker().addFrame(new CameraControlFrame()); Kernel.getWorker().addFrame(new IdolsFrame()); Kernel.getWorker().addFrame(new RoleplayIntroductionFrame()); Kernel.getWorker().addFrame(new ScreenCaptureFrame()); Kernel.getWorker().addFrame(new AdministrablePopupFrame()); if(FeatureManager.getInstance().isFeatureWithKeywordEnabled(""character.spell.forgettable"")) { Kernel.getWorker().addFrame(new ForgettableSpellsUiFrame()); } if(!Kernel.getWorker().contains(HouseFrame)) { Kernel.getWorker().addFrame(new HouseFrame()); } Kernel.getWorker().removeFrame(Kernel.getWorker().getFrame(GameStartingFrame)); Kernel.getWorker().resume(); ConnectionsHandler.resume(); if(Kernel.beingInReconection && !this._reconnectMsgSend) { this._reconnectMsgSend = true; ConnectionsHandler.getConnection().send(new CharacterSelectedForceReadyMessage()); } if(InterClientManager.getInstance().flashKey && (!PlayerManager.getInstance() || PlayerManager.getInstance().server.id != 129 && PlayerManager.getInstance().server.id != 130)) { flashKeyMsg = new ClientKeyMessage(); flashKeyMsg.initClientKeyMessage(InterClientManager.getInstance().flashKey); ConnectionsHandler.getConnection().send(flashKeyMsg); } if(this._cssmsg != null) { PlayedCharacterManager.getInstance().infos = this._cssmsg.infos; DataStoreType.CHARACTER_ID = this._cssmsg.infos.id.toString(); } Kernel.getWorker().removeFrame(this); if(XmlConfig.getInstance().getBooleanEntry(""config.dev.mode"")) { ModuleDebugManager.display(XmlConfig.getInstance().getBooleanEntry(""config.dev.auto.display.controler"")); Console.getInstance().display(!XmlConfig.getInstance().getBooleanEntry(""config.dev.auto.display.eventUtil"")); ConsoleLUA.getInstance().display(!XmlConfig.getInstance().getBooleanEntry(""config.dev.auto.display.luaUtil"")); if(XmlConfig.getInstance().getBooleanEntry(""config.dev.auto.display.fpsManager"")) { FpsManager.getInstance().display(); fpsManagerState = XmlConfig.getInstance().getEntry(""config.dev.auto.display.fpsManager.state""); if(fpsManagerState) { for(i = 0; i < fpsManagerState; i++) { FpsManager.getInstance().changeState(); } } } } else { Console.logChatMessagesOnly = true; Console.getInstance().activate(); } this._kernel.processCallback(HookList.GameStart); Kernel.getWorker().addFrame(new ServerTransferFrame()); gccrmsg = new GameContextCreateRequestMessage(); ConnectionsHandler.getConnection().send(gccrmsg); soundApi = new SoundApi(); soundApi.stopIntroMusic(); Shortcut.loadSavedData(); devMode = LangManager.getInstance().getEntry(""config.dev.mode"") == ""true""; if(devMode) { luaPlayer = ScriptsManager.getInstance().getPlayer(ScriptsManager.LUA_PLAYER) as LuaPlayer; if(!luaPlayer) { luaPlayer = new LuaPlayer(); ScriptsManager.getInstance().addPlayer(ScriptsManager.LUA_PLAYER,luaPlayer); ScriptsManager.getInstance().addPlayerApi(luaPlayer,""EntityApi"",new EntityApi()); ScriptsManager.getInstance().addPlayerApi(luaPlayer,""SeqApi"",new ScriptSequenceApi()); ScriptsManager.getInstance().addPlayerApi(luaPlayer,""CameraApi"",new CameraApi()); } } if(BuildInfos.BUILD_TYPE != BuildTypeEnum.DEBUG) { if(OptionManager.getOptionManager(""dofus"").getOption(""optimizeMultiAccount"")) { if(InterClientManager.isMaster()) { new DataApi().initStaticCartographyData(); } } else { new DataApi().initStaticCartographyData(); } } now = new Date().time; delta = now - this._loadingStart; if(delta > this.LOADING_TIMEOUT) { tag = {}; tag.duration = uint(delta / 1000); _log.warn(""Client took too long to load ("" + tag.duration + ""s), reporting.""); DofusErrorHandler.captureMessage(""Client loading timeout."",tag,RavenClient.WARN); } ChatServiceManager.getInstance().tryToConnect(); return true; case msg is ConnectionResumedMessage: return true; case msg is CharacterSelectedErrorMessage: csemsg = msg as CharacterSelectedErrorMessage; this._kernel.processCallback(HookList.CharacterImpossibleSelection,this._requestedCharacterId); this._requestedCharacterId = 0; return true; case msg is BasicTimeMessage: btmsg = msg as BasicTimeMessage; date = new Date(); TimeManager.getInstance().serverTimeLag = btmsg.timestamp + btmsg.timezoneOffset * 60 * 1000 - date.getTime(); TimeManager.getInstance().serverUtcTimeLag = btmsg.timestamp - date.getTime(); TimeManager.getInstance().timezoneOffset = btmsg.timezoneOffset * 60 * 1000; TimeManager.getInstance().dofusTimeYearLag = -1370; return true; case msg is StartupActionsListMessage: salm = msg as StartupActionsListMessage; this._giftList = []; for each(gift in salm.actions) { _items = []; for each(item in gift.items) { iw = ItemWrapper.create(0,0,item.objectGID,item.quantity,item.effects,false); _items.push(iw); } oj = { ""uid"":gift.uid, ""title"":gift.title, ""text"":gift.text, ""items"":_items }; this._giftList.push(oj); } if(this._giftList.length) { this._charaListMinusDeadPeople = []; for each(perso in this._charactersList) { if(!perso.deathState || perso.deathState == 0) { this._charaListMinusDeadPeople.push(perso); } } if(!Berilia.getInstance().getUi(""characterSelection"")) { this._kernel.processCallback(HookList.CharacterSelectionStart,this._charactersList); } else { this._kernel.processCallback(HookList.CharactersListUpdated,this._charactersList); } } else { Kernel.getWorker().removeFrame(this); _log.warn(""Empty Gift List Received""); } return true; case msg is GiftAssignRequestAction: gar = msg as GiftAssignRequestAction; sao = new StartupActionsObjetAttributionMessage(); sao.initStartupActionsObjetAttributionMessage(gar.giftId,gar.characterId); ConnectionsHandler.getConnection().send(sao); return true; case msg is StartupActionFinishedMessage: safm = msg as StartupActionFinishedMessage; indexToDelete = -1; for each(giftAction in this._giftList) { if(giftAction.uid == safm.actionId) { indexToDelete = this._giftList.indexOf(giftAction); break; } } if(indexToDelete > -1) { this._giftList.splice(indexToDelete,1); KernelEventsManager.getInstance().processCallback(HookList.GiftAssigned,safm.actionId); } return true; case msg is ConsoleCommandsListMessage: cclMsg = msg as ConsoleCommandsListMessage; for(cmdIndex = 0; cmdIndex < cclMsg.aliases.length; cmdIndex++) { new ServerCommand(cclMsg.aliases[cmdIndex],cclMsg.descriptions[cmdIndex]); } return true; case msg is GameRolePlayArenaSwitchToFightServerMessage: if(Kernel.getWorker().contains(ServerTransferFrame)) { return false; } stf = new ServerTransferFrame(); Kernel.getWorker().addFrame(stf); return stf.process(msg); break; case msg is PopupWarningClosedMessage: KernelEventsManager.getInstance().processCallback(HookList.PopupWarningClosed); return true; case msg is PopupWarningCloseRequestAction: pwcrmsg = new PopupWarningCloseRequestMessage(); pwcrmsg.initPopupWarningCloseRequestMessage(); ConnectionsHandler.getConnection().send(pwcrmsg); return true; } return false; } public function pulled() : Boolean { return true; } private function getCharacterColorsInformations(ctrci:*) : Vector. { var uIndexedColor:Number = NaN; var uIndex:int = 0; var uColor:* = 0; if(!ctrci || !ctrci.colors) { return null; } var charColors:Vector. = new Vector.(); for(var ic:int = 0; ic < ProtocolConstantsEnum.MAX_PLAYER_COLOR; ic++) { charColors.push(-1); } var num:int = ctrci.colors.length; for(var i:int = 0; i < num; i++) { uIndexedColor = ctrci.colors[i]; uIndex = (uIndexedColor >> 24) - 1; uColor = uIndexedColor & 16777215; if(uIndex > -1 && uIndex < charColors.length) { charColors[uIndex] = uColor; } } return charColors; } private function onEscapePopup() : void { Kernel.getInstance().reset(); } private function requestCharactersList() : void { var clrmsg:CharactersListRequestMessage = new CharactersListRequestMessage(); if(ConnectionsHandler && ConnectionsHandler.getConnection()) { ConnectionsHandler.getConnection().send(clrmsg); } } private function getCharacterToConnect() : BasicCharacterWrapper { var charToConnect:BasicCharacterWrapper = null; var charToConnectSpecificallyId:Number = NaN; var ctc:BasicCharacterWrapper = null; if((Dofus.getInstance().options && Dofus.getInstance().options.getOption(""autoConnectType"") == 2 || PlayerManager.getInstance().autoConnectOfASpecificCharacterId > -1) && PlayerManager.getInstance().allowAutoConnectCharacter) { charToConnectSpecificallyId = PlayerManager.getInstance().autoConnectOfASpecificCharacterId; if(charToConnectSpecificallyId == -1) { if(this._charactersList.length <= 0) { return null; } charToConnect = this._charactersList[0]; } else { for each(ctc in this._charactersList) { if(ctc.id == charToConnectSpecificallyId) { charToConnect = ctc; break; } } } return charToConnect; } return null; } private function launchAutoConnect(charToConnect:BasicCharacterWrapper, server:Server) : void { var updateInformationDisplayed:String = null; var currentVersion:String = null; var fakacsa:CharacterSelectionAction = null; if(charToConnect && ((!FeatureManager.getInstance().isFeatureWithKeywordEnabled(""server.heroic"") && server.gameTypeId != GameServerTypeEnum.SERVER_TYPE_EPIC || charToConnect.deathState == 0) && !SecureModeManager.getInstance().active && !this.isCharacterWaitingForChange(charToConnect.id) && !PlayerManager.getInstance().wasAlreadyConnected)) { this._openCharsList = false; this._kernel.processCallback(HookList.CharactersListUpdated,this._charactersList); updateInformationDisplayed = StoreDataManager.getInstance().getData(new DataStoreType(""ComputerModule_Ankama_Connection"",true,DataStoreEnum.LOCATION_LOCAL,DataStoreEnum.BIND_COMPUTER),""updateInformationDisplayed""); currentVersion = BuildInfos.VERSION.major.toString() + ""-"" + BuildInfos.VERSION.minor.toString(); if(updateInformationDisplayed == currentVersion) { fakacsa = new CharacterSelectionAction(); fakacsa.btutoriel = false; fakacsa.characterId = charToConnect.id; this.process(fakacsa); PlayerManager.getInstance().allowAutoConnectCharacter = false; } } } } } ",12090,False,2133.1912735646292,median "/* Feathers Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. This program is free software. You can redistribute and/or modify it in accordance with the terms of the accompanying license agreement. */ package feathers.controls { import feathers.core.FeathersControl; import feathers.core.PropertyProxy; import feathers.core.ToggleGroup; import feathers.data.ListCollection; import feathers.events.CollectionEventType; import feathers.layout.HorizontalLayout; import feathers.layout.LayoutBoundsResult; import feathers.layout.VerticalLayout; import feathers.layout.ViewPortBounds; import starling.display.DisplayObject; import starling.events.Event; /** * Dispatched when the selected tab changes. * *

The properties of the event object have the following values:

* * * * * * *
PropertyValue
bubblesfalse
currentTargetThe Object that defines the * event listener that handles the event. For example, if you use * myButton.addEventListener() to register an event listener, * myButton is the value of the currentTarget.
datanull
targetThe Object that dispatched the event; * it is not always the Object listening for the event. Use the * currentTarget property to always access the Object * listening for the event.
* * @eventType starling.events.Event.CHANGE */ [Event(name=""change"",type=""starling.events.Event"")] [DefaultProperty(""dataProvider"")] /** * A line of tabs (vertical or horizontal), where one may be selected at a * time. * *

The following example sets the data provider, selects the second tab, * and listens for when the selection changes:

* * * var tabs:TabBar = new TabBar(); * tabs.dataProvider = new ListCollection( * [ * { label: ""One"" }, * { label: ""Two"" }, * { label: ""Three"" }, * ]); * tabs.selectedIndex = 1; * tabs.addEventListener( Event.CHANGE, tabs_changeHandler ); * this.addChild( tabs ); * * @see http://wiki.starling-framework.org/feathers/tab-bar */ public class TabBar extends FeathersControl { /** * @private */ protected static const INVALIDATION_FLAG_TAB_FACTORY:String = ""tabFactory""; /** * @private */ protected static const NOT_PENDING_INDEX:int = -2; /** * @private */ private static const DEFAULT_TAB_FIELDS:Vector. = new [ ""defaultIcon"", ""upIcon"", ""downIcon"", ""hoverIcon"", ""disabledIcon"", ""defaultSelectedIcon"", ""selectedUpIcon"", ""selectedDownIcon"", ""selectedHoverIcon"", ""selectedDisabledIcon"" ]; /** * The tabs are displayed in order from left to right. * * @see #direction */ public static const DIRECTION_HORIZONTAL:String = ""horizontal""; /** * The tabs are displayed in order from top to bottom. * * @see #direction */ public static const DIRECTION_VERTICAL:String = ""vertical""; /** * The tabs will be aligned horizontally to the left edge of the tab * bar. * * @see #horizontalAlign */ public static const HORIZONTAL_ALIGN_LEFT:String = ""left""; /** * The tabs will be aligned horizontally to the center of the tab bar. * * @see #horizontalAlign */ public static const HORIZONTAL_ALIGN_CENTER:String = ""center""; /** * The tabs will be aligned horizontally to the right edge of the tab * bar. * * @see #horizontalAlign */ public static const HORIZONTAL_ALIGN_RIGHT:String = ""right""; /** * If the direction is vertical, each tab will fill the entire width of * the tab bar, and if the direction is horizontal, the alignment will * behave the same as HORIZONTAL_ALIGN_LEFT. * * @see #horizontalAlign * @see #direction */ public static const HORIZONTAL_ALIGN_JUSTIFY:String = ""justify""; /** * The tabs will be aligned vertically to the top edge of the tab bar. */ public static const VERTICAL_ALIGN_TOP:String = ""top""; /** * The tabs will be aligned vertically to the middle of the tab bar. * * @see #verticalAlign */ public static const VERTICAL_ALIGN_MIDDLE:String = ""middle""; /** * The tabs will be aligned vertically to the bottom edge of the tab * bar. * * @see #verticalAlign */ public static const VERTICAL_ALIGN_BOTTOM:String = ""bottom""; /** * If the direction is horizontal, each tab will fill the entire height * of the tab bar. If the direction is vertical, the alignment will * behave the same as VERTICAL_ALIGN_TOP. * * @see #verticalAlign * @see #direction */ public static const VERTICAL_ALIGN_JUSTIFY:String = ""justify""; /** * The default value added to the nameList of the tabs. * * @see feathers.core.IFeathersControl#nameList */ public static const DEFAULT_CHILD_NAME_TAB:String = ""feathers-tab-bar-tab""; /** * @private */ protected static function defaultTabFactory():Button { return new Button(); } /** * Constructor. */ public function TabBar() { } /** * The value added to the nameList of the tabs. This * variable is protected so that sub-classes can customize * the tab name in their constructors instead of using the default * name defined by DEFAULT_CHILD_NAME_TAB. * *

To customize the tab name without subclassing, see * customTabName.

* * @see #customTabName * @see feathers.core.IFeathersControl#nameList */ protected var tabName:String = DEFAULT_CHILD_NAME_TAB; /** * The value added to the nameList of the first tab. This * variable is protected so that sub-classes can customize * the first tab name in their constructors instead of using the default * name defined by DEFAULT_CHILD_NAME_TAB. * *

To customize the first tab name without subclassing, see * customFirstTabName.

* * @see #customFirstTabName * @see feathers.core.IFeathersControl#nameList */ protected var firstTabName:String = DEFAULT_CHILD_NAME_TAB; /** * The value added to the nameList of the last tab. This * variable is protected so that sub-classes can customize * the last tab name in their constructors instead of using the default * name defined by DEFAULT_CHILD_NAME_TAB. * *

To customize the last tab name without subclassing, see * customLastTabName.

* * @see #customLastTabName * @see feathers.core.IFeathersControl#nameList */ protected var lastTabName:String = DEFAULT_CHILD_NAME_TAB; /** * The toggle group. */ protected var toggleGroup:ToggleGroup; /** * @private */ protected var activeFirstTab:Button; /** * @private */ protected var inactiveFirstTab:Button; /** * @private */ protected var activeLastTab:Button; /** * @private */ protected var inactiveLastTab:Button; /** * @private */ protected var _layoutItems:Vector. = new []; /** * @private */ protected var activeTabs:Vector.