예제 #1
0
static PyObject* directWrite(PyObject* self, PyObject* arg)
{
	PyObject* transferTuple;
	unsigned int offset, returnVal ;

	if(!PyArg_ParseTuple(arg, "lO", &offset, &transferTuple))		
		return NULL;					

	if(!PyTuple_Check(transferTuple))			
		pabort("Only accepts a single tuple as an argument\n");


	uint32_t tupleSize = PyTuple_Size(transferTuple);
	uint8_t tx[tupleSize];
	PyObject* tempItem;
	uint32_t i=0;
	while(i < tupleSize)
	{
		tempItem = PyTuple_GetItem(transferTuple, i);		//
		if(!PyInt_Check(tempItem))
		{
			pabort("non-integer contained in tuple\n");
		}
		tx[i] = (uint8_t)PyInt_AsSsize_t(tempItem);
		i++;

	}
	returnVal = direct_write(offset, tx, tupleSize);
	return Py_BuildValue("l", returnVal) ;
}
예제 #2
0
파일: misc.cpp 프로젝트: chys87/tiary
bool safe_write_file(const char *filename, std::string_view data, std::string_view data2) {
	if (must_direct_write(filename)) {
		// If filename is not a regular file, or has multiple links, there is only one choice
		return direct_write(filename, data, data2);
	} else {
		// Otherwise, write to a temporary file and rename it
		std::string tmp_name = filename;
		tmp_name += ".tiary.tmp";
		if (!direct_write(tmp_name.c_str(), data, data2)) {
			unlink(tmp_name.c_str());
			return false;
		}
		if (rename(tmp_name.c_str(), filename) != 0) {
			unlink(tmp_name.c_str());
			return false;
		}
		return true;
	}
}
예제 #3
0
void LCD_MODULE::lcd_init(GSplash splash)
{
#if GUI_DISPLAYS > 1
	if(display == 1)
#endif
	{
		usr_task_init_static(&backlight_task_desc, false);
		backlight_task.sp->r0.as_voidptr = this;
		usr_task_schedule(backlight_task_desc.tsk);
	}

	// LCD Reset
	PIO_CfgOutput0(pins[RST_PIN_INDX]);
	tsk_sleep(20);
	PIO_SetOutput(pins[RST_PIN_INDX]);
	tsk_sleep(20);

    //LCD Handle initialization (LCD attached to SPI)
    lcd_hnd->tsk_safe_open(lcd_hnd->drv_index, lcd_hnd->mode.as_voidptr);
    lcd_reset();
    direct_write(splash);
}