Exemplo n.º 1
0
void MicroBitDisplay::render()
{
    // Simple optimisation.
    // If display is at zero brightness, there's nothing to do.
    if(brightness == 0)
        return;

    // Calculate the bitpattern to write.
    uint32_t row_data = 0x01 << (microbitMatrixMap.rowStart + strobeRow);
    uint32_t col_data = 0;

    for (int i = 0; i < matrixMap.columns; i++)
    {
        int index = (i * matrixMap.rows) + strobeRow;

        int x = matrixMap.map[index].x;
        int y = matrixMap.map[index].y;
        int t = x;

        if(rotation == MICROBIT_DISPLAY_ROTATION_90)
        {
                x = width - 1 - y;
                y = t;
        }

        if(rotation == MICROBIT_DISPLAY_ROTATION_180)
        {
                x = width - 1 - x;
                y = height - 1 - y;
        }

        if(rotation == MICROBIT_DISPLAY_ROTATION_270)
        {
                x = y;
                y = height - 1 - t;
        }

        if(image.getBitmap()[y*(width*2)+x])
            col_data |= (1 << i);
    }

    // Invert column bits (as we're sinking not sourcing power), and mask off any unused bits.
    col_data = ~col_data << matrixMap.columnStart & col_mask;

    // Write the new bit pattern
    *LEDMatrix = col_data | row_data;

    //timer does not have enough resolution for brightness of 1. 23.53 us
    if(brightness != MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS && brightness > MICROBIT_DISPLAY_MINIMUM_BRIGHTNESS)
        renderTimer.attach_us(this, &MicroBitDisplay::renderFinish, (((brightness * 950) / (MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS)) * system_timer_get_period()));

    //this will take around 23us to execute
    if(brightness <= MICROBIT_DISPLAY_MINIMUM_BRIGHTNESS)
        renderFinish();
}
Exemplo n.º 2
0
void DFSGridGraphSolver::render()
{
	glColor3f(0, 1, 0); //pure green
	std::vector<PathNodeT>::iterator iter;
	GridNode* from = m_start;
	for (iter = m_path.begin(); iter != m_path.end(); iter++) {
		drawPathSegment(from, (*iter).node);
		from = (*iter).node;
	}

	renderStart();
	renderFinish();
}
Exemplo n.º 3
0
void MyBFSGridGraphSolver::render() {
	//open list iterator

	//draw open list as gray circle-with-tale
	renderOpenAndClosedLists();

	//draw path
	if (m_state == SOLVED) {
		glColor3f(0, 1, 0); //pure green
		std::vector<PathNodeT *>::iterator iter;
		PathNodeT* from = *m_path.begin();
		for (iter = m_path.begin(); iter != m_path.end(); iter++) {
			drawPathSegment(from->m_node, (*iter)->m_node);
			from = (*iter);
		}
	}
	renderStart();
	renderFinish();
}