void Terrain::CreateDebugTerrain( int seed ) { Tiles.clear(); { int tmp = Engine::getCfg()->get<float>("sim.terragen.debug.size"); Size = glm::ivec2( tmp, tmp ); } // maximum height to generate float maxHeight = Engine::getCfg()->get<float>("sim.terragen.debug.maxheight"); //float minheight = 0; float maxFallofDist = Size.x/2; float waterlimit = Engine::getCfg()->get<float>("sim.terragen.debug.waterlimit"); glm::point2 Mid = glm::point2( Size.x/2, Size.y/2 ); std::mt19937 gen(seed); std::uniform_real_distribution<float> rnd; std::uniform_real_distribution<float> nutritionrnd(Engine::getCfg()->get<float>("sim.terragen.debug.nutrition.min"), Engine::getCfg()->get<float>("sim.terragen.debug.nutrition.max")); float minHumidity = Engine::getCfg()->get<float>("sim.terragen.debug.humidity.min"); float maxHumidity = Engine::getCfg()->get<float>("sim.terragen.debug.humidity.max"); for ( int y = 0; y < Size.y; ++y) { for ( int x = 0; x < Size.x; ++x) { glm::point2 TileMid = glm::point2( x+.5, y+.5 ); float HeightFactor = (1 - glm::distance( TileMid, Mid )/maxFallofDist ); HeightFactor = HeightFactor < 0 ? 0 : HeightFactor; float TileHeight = maxHeight*HeightFactor; Tile *tmp = new Tile( glm::ipoint2(x,y), TileHeight, nutritionrnd(gen), ((TileHeight < waterlimit)?1:0)); std::shared_ptr<Tile> T(tmp); Tiles.push_back ( T ); } } calculateHumidity(); }
/* * Function:makeHTmeasurements(void) * -------------------- * Function used to run the sequence of measurements: * 1.Read RH * 2.Calculate Humidity value * 3.Get last temperature measurement after RH measurement was done * 4.Calculate temperature value * 5.Update the display with new values. */ void makeHTmeasurements(void) { measureRH(); humidityValue = calculateHumidity(humidityCode); getLastTemp(); temperatureValue = calculateTemperature(temperatureCode); char str[10]; char humm[10]; sprintf(str, "%d", temperatureValue); oled_prints(30, 6, str); sprintf(humm, "%d", humidityValue); oled_prints(45, 8, humm); oled_render(); UART1PutStr(str); }