コード例 #1
0
ファイル: mazegen.c プロジェクト: clamiax/misc
void
maze_gen(short int *grid, int TotalCells) {
	int CurrentCell = random() / (RAND_MAX / TotalCells + 1);
	int VisitedCells = 1;
	int AdCell; /* Adiacent cell */
	int *stack, top = 0;
	int i;

	if(! (stack = malloc(sizeof(int) * TotalCells)))
		return;

	for(i = 0; i < rows * cols; i++)
		grid[i] = A << WALLS;

	while(VisitedCells < TotalCells) {
		if((AdCell = nextcell(grid, CurrentCell)) != -1) {
			pulldown(grid, CurrentCell, AdCell);

			push(stack, &top, CurrentCell);
			CurrentCell = AdCell;
			++VisitedCells;
		}
		else
			CurrentCell = pop(stack, &top);
	}
}
コード例 #2
0
/*
|| <<constructor>>
|| @parameter buttonPin sets the pin that this switch is connected to
|| @parameter buttonMode indicates PULLUP or PULLDOWN resistor
*/
Button::Button(uint8_t buttonPin, uint8_t buttonMode){
	this->pin=buttonPin;
    pinMode(pin,INPUT);
	buttonMode==PULLDOWN ? pulldown() : pullup();
    state = 0;
    bitWrite(state,CURRENT,!mode);
}
コード例 #3
0
ファイル: Button.cpp プロジェクト: zad80/Breaduino
void CButton::begin()
{
	Module::begin();
    pinMode(pin,INPUT);

	mode==PULLDOWN ? pulldown() : pullup();
    state = 0;
    timing[CHANGED] = timing[PREVIOUS] = timing[CURRENT] = 0;
    bitWrite(state,CURRENT,!mode);
    stopCountingSequence=shortCounted=longCounted=false;
}
コード例 #4
0
ファイル: main.c プロジェクト: LambdaCalculus379/SLS-1.02
Menu* App::menubar(CmdInfo* info, WidgetKit& kit, const LayoutKit& layout) {
    Menu* m = kit.menubar();
    for (CmdInfo* i = info; i->str != nil; i++) {
	MenuItem* mi = kit.menubar_item(kit.fancy_label(i->str));
	mi->menu(pulldown(i->submenu, i->options, kit, layout));
	m->append_item(mi);
    }
    m->item(0)->menu()->item(1)->state()->set(
	TelltaleState::is_enabled, false
    );
    return m;
}
コード例 #5
0
ファイル: Button.cpp プロジェクト: insolace/beatseqr-software
/*
|| @constructor
|| | Set the initial state of this button
|| #
|| 
|| @parameter buttonPin  sets the pin that this switch is connected to
|| @parameter buttonMode indicates BUTTON_PULLUP or BUTTON_PULLDOWN resistor
*/
Button::Button(uint8_t buttonPin, uint8_t buttonMode){
  pin=buttonPin;
  pinMode(pin,INPUT);
  
  buttonMode==BUTTON_PULLDOWN ? pulldown() : pullup(buttonMode);
  state = 0;
  bitWrite(state,CURRENT,!mode);
  
  cb_onPress = 0;
  cb_onRelease = 0;
  cb_onClick = 0;
  cb_onHold = 0;
  
  numberOfPresses = 0;
  triggeredHoldEvent = true;
}
コード例 #6
0
/*
|| @constructor
|| | Set the initial state of this button
|| #
|| 
|| @parameter buttonPin  sets the pin that this switch is connected to
|| @parameter buttonMode indicates BUTTON_PULLUP or BUTTON_PULLDOWN resistor
*/
Button::Button(uint8_t buttonPin, uint8_t buttonMode, bool _debounceMode, int _debounceDuration){
	pin=buttonPin;
  pinMode(pin,INPUT);
  
  debounceMode = _debounceMode;
  debounceDuration = _debounceDuration;
  debounceStartTime = millis();

	buttonMode==BUTTON_PULLDOWN ? pulldown() : pullup(buttonMode);
  state = 0;
  bitWrite(state,CURRENT,!mode);
  
  cb_onPress = 0;
  cb_onRelease = 0;
  cb_onClick = 0;
  cb_onHold = 0;
  
  numberOfPresses = 0;
  triggeredHoldEvent = true;
}
コード例 #7
0
ファイル: main.c プロジェクト: LambdaCalculus379/SLS-1.02
Menu* App::pulldown(
    CmdInfo* info, int opt, WidgetKit& k, const LayoutKit& layout
) {
    Menu* m = k.pulldown();
    TelltaleGroup* group = nil;
    for (CmdInfo* i = info; i->str != nil; i++) {
        if (i->str[0] == '\0') {
            m->append_item(k.menu_item_separator());
        } else {
	    Glyph* g = layout.r_margin(
		k.fancy_label(i->str), 0.0, fil, 0.0
	    );
	    MenuItem* mi;
	    switch (opt) {
	    case 1:
		mi = k.check_menu_item(g);
		break;
	    case 2:
		if (group == nil) {
		    group = new TelltaleGroup;
		}
		mi = k.radio_menu_item(group, g);
		break;
	    default:
		mi = k.menu_item(g);
		break;
	    }
	    if (i->func == nil && i->submenu != nil) {
		mi->menu(pulldown(i->submenu, i->options, k, layout));
	    } else {
		mi->action(new ActionCallback(App)(this, i->func));
	    }
	    m->append_item(mi);
        }
    }
    return m;
}