static void on(struct IPwm * base) { uint8_t const Compare_440_Hz = 70; uint8_t const Prescaler_256 = 0x04; TCCR0A = bit_value(COM0A0) | bit_value(WGM01) | bit_value(WGM00); TCCR0B = bit_value(WGM02) | Prescaler_256; OCR0A = Compare_440_Hz; }
void bloomenthal_polygonizer::PolygonizeSurface(const Location& startinglocation) { // Create initial cube if(mark_center(startinglocation)) return; Cube c(startinglocation); for(TqInt n = 0; n < 8; n++) c.corners[n] = get_cached_corner(startinglocation + Location(bit_value(n, 2), bit_value(n, 1), bit_value(n, 0))); // Push it on stack m_active_cubes.push(c); // Process active cubes till none left while(!m_active_cubes.empty()) { Cube c = m_active_cubes.top(); m_active_cubes.pop(); // Polygonize switch(m_Decomposition) { case MARCHINGCUBES: MarchingCube(c); break; case TETRAHEDRAL: // Decompose into tetrahedra and polygonize TriangulateTet(c, LBN, LTN, RBN, LBF); TriangulateTet(c, RTN, LTN, LBF, RBN); TriangulateTet(c, RTN, LTN, LTF, LBF); TriangulateTet(c, RTN, RBN, LBF, RBF); TriangulateTet(c, RTN, LBF, LTF, RBF); TriangulateTet(c, RTN, LTF, RTF, RBF); break; default: Aqsis::log() << warning << "Unknow decomposition " << std::endl; MarchingCube(c); break; } // Test six face directions, maybe add to stack TestFace(c.l.Left(), c, L, LBN, LBF, LTN, LTF); TestFace(c.l.Right(), c, R, RBN, RBF, RTN, RTF); TestFace(c.l.Bottom(), c, B, LBN, LBF, RBN, RBF); TestFace(c.l.Top(), c, T, LTN, LTF, RTN, RTF); TestFace(c.l.Near(), c, N, LBN, LTN, RBN, RTN); TestFace(c.l.Far(), c, F, LBF, LTF, RBF, RTF); } }
list< AlertEvent > AlertValue::check( unsigned int alert_id, int type, time_t gps_time ) { list< AlertEvent > list_event; AlertInfo *pmap = NULL; unsigned int *pbit_map = NULL; if ( type == ALERT808 ) { pmap = map808; pbit_map = & bit_map808; } else { pmap = map808b; pbit_map = & bit_map808b; } unsigned int change_map = ( alert_id ) ^ ( * pbit_map ); for ( int i = 0 ; i < 32 ; i ++ ) { if ( bit_value( change_map, i ) ) { //报警从无到有 if ( bit_value( alert_id, i ) ) { pmap[i].begin_time = gps_time; pmap[i].end_time = 0; AlertEvent alert_event; alert_event.event = IDataPool::insert; alert_event.alert_info = pmap[i]; alert_event.single_alert_id = alert_value( i ); list_event.push_back( alert_event ); } else { //从有到无 AlertEvent alert_event; alert_event.event = IDataPool::update; alert_event.single_alert_id = alert_value( i ); alert_event.alert_info.begin_time = pmap[i].begin_time; alert_event.alert_info.end_time = gps_time; list_event.push_back( alert_event ); pmap[i].reset(); } } } * pbit_map = alert_id; return list_event; }
// Create the 256 entry table for cubical polygonization void bloomenthal_polygonizer::MakeCubeTable() { for(TqInt configuration = 0; configuration < 256; configuration++) { std::vector< std::vector<TqInt> > triangles; TqInt edge; TqInt bits[8]; for(TqInt c = 0; c < 8; c++) bits[c] = bit_value(configuration, c); bool done[12]; for(edge = 0; edge < 12; edge++) done[edge] = false; for( edge = 0; edge < 12; edge++) if(!done[edge] && (bits[mc::corner1[edge]] != bits[mc::corner2[edge]])) { std::vector<TqInt> triangle; // Get face that is to right of edge from pos to neg corner TqInt face = bits[mc::corner1[edge]] ? mc::rightface[edge] : mc::leftface[edge]; TqInt startingedge = edge, currentedge = edge; do { currentedge = mc::next_edge(currentedge, face); done[currentedge] = true; if(bits[mc::corner1[currentedge]] != bits[mc::corner2[currentedge]]) { triangle.push_back(currentedge); // face adjoining edge that is not the given face if(face == mc::leftface[currentedge]) face = mc::rightface[currentedge]; else face = mc::leftface[currentedge]; } } while(currentedge != startingedge); triangles.push_back(triangle); } m_CubeTable.push_back(triangles); } for(TqInt i = 0, numI = m_CubeTable.size(); i < numI; i++) for(TqInt j = 0, numJ = m_CubeTable[i].size(); j < numJ; j++) std::reverse(m_CubeTable[i][j].begin(), m_CubeTable[i][j].end()); }
void bloomenthal_polygonizer::TestFace(const Location& facelocation, Cube& old, TqInt face, TqInt c1, TqInt c2, TqInt c3, TqInt c4) { // No surface crossing? bool pos = old.corners[c1]->value >= m_Threshold; if(((old.corners[c2]->value >= m_Threshold) == pos) && ((old.corners[c3]->value >= m_Threshold) == pos) && ((old.corners[c4]->value >= m_Threshold) == pos)) return; // Out of bounds? if(m_keep_within_limits && !(m_MinCorner <= facelocation && facelocation < m_MaxCorner)) return; // Already visited? if(mark_center(facelocation)) return; // Create new cube and add it to top of stack Cube newc(facelocation); const TqInt facebit[6] = { 2, 2, 1, 1, 0, 0 }; TqInt bit = facebit[face]; newc.corners[invert_bit(c1, bit)] = old.corners[c1]; newc.corners[invert_bit(c2, bit)] = old.corners[c2]; newc.corners[invert_bit(c3, bit)] = old.corners[c3]; newc.corners[invert_bit(c4, bit)] = old.corners[c4]; for(TqInt n = 0; n < 8; n++) if(!newc.corners[n]) newc.corners[n] = get_cached_corner(facelocation + Location(bit_value(n, 2), bit_value(n, 1), bit_value(n, 0))); m_active_cubes.push(newc); }
void show_p(){ int i; printf ("\n"); //SHOW GPIO Port 0 (directly) i= inpw (0xfff83000); printf ("\nGPIO_CFG0 0xFFF830000 Value: %d\n",i); printf ("\nPT0CFG0: %d %d", bit_value(i,0),bit_value(i,1)); printf ("\nPT0CFG1: %d %d", bit_value(i,2),bit_value(i,3)); printf ("\nPT0CFG2: %d %d", bit_value(i,4),bit_value(i,5)); printf ("\nPT0CFG3: %d %d", bit_value(i,6),bit_value(i,7)); printf ("\nPT0CFG4: %d %d", bit_value(i,8),bit_value(i,9)); printf ("\n"); //SHOW GPIO_DIR0 i= inpw (0xFFF83004); printf ("\nGPIO_DIR0 0xFFF83004 Value: %d\n",i); printf ("\nOMDEN0[4:0]: %d %d %d %d %d\n", bit_value (i,0), bit_value(i,1), bit_value (i,2),bit_value (i,3), bit_value(i,4) ); printf ("\nPUPEN0[3:0]: %d %d %d %d\n", bit_value(i,16), bit_value(i,17), bit_value(i,18), bit_value (i,19)); //SHOW GPIO_DATAOUT0 i= inpw (0xFFF83008); printf ("\nDATAOUT0: Value is: %d\n",i); i=i <<3; i=i >>3; printf ("\nDATAOUT0: Bitwise cleared value is: %d \n",i); /* //SHOW GPIO location VAL printf ("\nUSING GPIO + val: %d\n",val); j = (unsigned int)GPIO_OFFSET+val; printf ("\nUsing GPIO Value %X\n",j); i = inpw (j); printf ("GPIO 1 Port 0 LOC=%X vs 0xFFF83020? Value: %d\n",j,i); printf ("PT0CFG0: %d %d", bit_value(i,0),bit_value(i,1)); printf ("\nPT0CFG1: %d %d", bit_value(i,2),bit_value(i,3)); printf ("\nPT0CFG2: %d %d", bit_value(i,4),bit_value(i,5)); printf ("\nPT0CFG3: %d %d", bit_value(i,6),bit_value(i,7)); printf ("\nPT0CFG4: %d %d", bit_value(i,8),bit_value(i,9)); printf ("\n"); */ //SHOW GPIO PORT 1 CONFIG REGISTER i = inpw (0xfff83010); printf ("\nGPIO Port 1 0xFFF83010 CONFIG REGISTER Value: %d\n",i); printf ("\nPT1CFG0: %d %d", bit_value(i,0),bit_value(i,1)); printf ("\nPT1CFG1: %d %d", bit_value(i,2),bit_value(i,3)); printf ("\n"); //SHOW GPIO_DIR1 i= inpw (0xFFF83014); printf ("\nGPIO_DIR1 0xFFF83014 Value: %d\n",i); printf ("\nOMDEN2[7:0]: %d %d %d %d %d %d %d\n", bit_value (i,0), bit_value(i,1), bit_value (i,2),bit_value (i,3), bit_value(i,4), bit_value (i,5), bit_value(i,6), bit_value (i,7)); printf ("\nOMDEN2[9:8]: %d %d\n", bit_value(i,8), bit_value (i,9)); //SHOW GPIO_CFG2 i = inpw (0xFFF83020); printf ("\nGPIO_CFG2 0xFFF83020 Value: %d\n",i); printf ("\nPT2CFG0: %d %d", bit_value(i,0),bit_value(i,1)); printf ("\nPT2CFG1: %d %d", bit_value(i,2),bit_value(i,3)); printf ("\nPT2CFG2: %d %d", bit_value(i,4),bit_value(i,5)); printf ("\nPT2CFG3: %d %d", bit_value(i,6),bit_value(i,7)); printf ("\nPT2CFG4: %d %d", bit_value(i,8),bit_value(i,9)); printf ("\nPT2CFG0: %d %d", bit_value(i,10),bit_value(i,11)); printf ("\nPT2CFG1: %d %d", bit_value(i,12),bit_value(i,13)); printf ("\nPT2CFG2: %d %d", bit_value(i,14),bit_value(i,15)); printf ("\nPT2CFG3: %d %d", bit_value(i,16),bit_value(i,17)); printf ("\nPT2CFG4: %d %d", bit_value(i,18),bit_value(i,19)); printf ("\n"); //SHOW GPIO_DIR2 i= inpw (0xFFF83024); printf ("\nGPIO_DIR2 0xFFF83024 Value: %d\n",i); printf ("\nOMDEN2[7:0]: %d %d %d %d %d %d %d %d\n", bit_value (i,0), bit_value(i,1), bit_value (i,2),bit_value (i,3), bit_value(i,4), bit_value (i,5), bit_value(i,6), bit_value (i,7)); printf ("\nOMDEN2[9:8]: %d %d\n", bit_value(i,8), bit_value (i,9)); printf ("\nPUPEN2: %d %d %d %d %d %d %d %d %d",bit_value(i,0),bit_value(i,1), bit_value (i,2),bit_value (i,3), bit_value(i,4), bit_value (i,5), bit_value(i,6), bit_value (i,7), bit_value(i,8), bit_value (i,9)); //SHOW GPIO_CFG4 i = inpw (0xFFF83040); printf ("\nGPIO_CFG4 0xFFF83040 Value: %d\n",i); printf ("\nPT4CFG10: %d %d", bit_value(i,20),bit_value(i,21)); printf ("\n"); //SHOW GPIO_DIR4 i= inpw (0xFFF83044); printf ("\nGPIO_DIR4 0xFFF83044 Value: %d\n",i); printf ("\nOMDEN4[10]: %d\n", bit_value (i,10)); printf ("\nPUPEN4[10]: %d\n", bit_value (i,26)); //SHOW GPIO_CFG5 i = inpw (0xFFF83050); printf ("\nGPIO_CFG5 0xFFF83050 Value: %d\n",i); printf ("\nPT5CFG0: %d %d", bit_value(i,0), bit_value(i,1)); printf ("\nPT5CFG1: %d %d", bit_value(i,2), bit_value(i,3)); printf ("\nPT5CFG2: %d %d", bit_value(i,4), bit_value(i,5)); printf ("\nPT5CFG3: %d %d", bit_value(i,6), bit_value(i,7)); printf ("\nPT5CFG4: %d %d", bit_value(i,8), bit_value(i,9)); printf ("\nPT5CFG5: %d %d", bit_value(i,10),bit_value(i,11)); printf ("\nPT5CFG6: %d %d", bit_value(i,12),bit_value(i,13)); printf ("\nPT5CFG7: %d %d", bit_value(i,14),bit_value(i,15)); printf ("\nPT5CFG8: %d %d", bit_value(i,16),bit_value(i,17)); printf ("\nPT5CFG9: %d %d", bit_value(i,18),bit_value(i,19)); printf ("\nPT5CFG10: %d %d", bit_value(i,20),bit_value(i,21)); printf ("\nPT5CFG11: %d %d", bit_value(i,22),bit_value(i,23)); printf ("\nPT5CFG12: %d %d", bit_value(i,24),bit_value(i,25)); printf ("\n"); //SHOW GPIO_DIR5 i= inpw (0xFFF83054); printf ("\nGPIO_DIR5 0xFFF83054 Value: %d\n",i); printf ("\nOMDEN5[7:0]: %d %d %d %d %d %d %d %d\n", bit_value (i,0), bit_value(i,1), bit_value (i,2),bit_value (i,3), bit_value(i,4), bit_value (i,5), bit_value(i,6), bit_value (i,7)); printf ("\nOMDEN5[12:8]: %d %d %d %d %d\n", bit_value(i,8), bit_value (i,9), bit_value(i,10), bit_value(i,11), bit_value(i,12)); printf ("\nPUPEN5[7:0]: %d %d %d %d %d %d %d %d\n", bit_value (i,16), bit_value(i,17), bit_value (i,18),bit_value (i,19), bit_value(i,20), bit_value (i,21), bit_value(i,22), bit_value (i,23)); printf ("\nPUPEN5[12:8]: %d %d %d %d %d\n", bit_value(i,24), bit_value (i,25), bit_value(i,26), bit_value(i,27), bit_value(i,28)); printf ("\n\n");//Putting it here, as we'll be adding lots of other shit above... }